-
-
Save M1chaelTran/f22ac7c48466e8970f932ab743043e79 to your computer and use it in GitHub Desktop.
@echo off | |
:: change the path below to match your installed version | |
SET WebStormPath=C:\Program Files\JetBrains\WebStorm 2017.2.2\bin\webstorm64.exe | |
echo Adding file entries | |
@reg add "HKEY_CLASSES_ROOT\*\shell\WebStorm" /t REG_SZ /v "" /d "Open with WebStorm" /f | |
@reg add "HKEY_CLASSES_ROOT\*\shell\WebStorm" /t REG_EXPAND_SZ /v "Icon" /d "%WebStormPath%,0" /f | |
@reg add "HKEY_CLASSES_ROOT\*\shell\WebStorm\command" /t REG_SZ /v "" /d "%WebStormPath% \"%%1\"" /f | |
echo Adding within a folder entries | |
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\WebStorm" /t REG_SZ /v "" /d "Open with WebStorm" /f | |
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\WebStorm" /t REG_EXPAND_SZ /v "Icon" /d "%WebStormPath%,0" /f | |
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\WebStorm\command" /t REG_SZ /v "" /d "%WebStormPath% \"%%V\"" /f | |
echo Adding folder entries | |
@reg add "HKEY_CLASSES_ROOT\Directory\shell\WebStorm" /t REG_SZ /v "" /d "Open with WebStorm" /f | |
@reg add "HKEY_CLASSES_ROOT\Directory\shell\WebStorm" /t REG_EXPAND_SZ /v "Icon" /d "%WebStormPath%,0" /f | |
@reg add "HKEY_CLASSES_ROOT\Directory\shell\WebStorm\command" /t REG_SZ /v "" /d "%WebStormPath% \"%%1\"" /f | |
pause |
Thank you.
And there is how to remove these reg entries:
@echo off
echo Deleting file entries
@reg delete "HKEY_CLASSES_ROOT\*\shell\WebStorm"
echo Deleting within a folder entries
@reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\WebStorm"
echo Deleting folder entries
@reg delete "HKEY_CLASSES_ROOT\Directory\shell\WebStorm"
pause
Can this script be modified to not rely on specific path to WebStorm so I won't need to redo this every time I install some new version of Webstorm?
You can enable an option in Toolbox to generate Shell scripts. You just specify a folder where to generate these scripts.
Here is my solution:@echo off :: change the path below to match your installed version SET WebStormPath=d:\dev\apps\jetbrains\shell-scripts\webstorm.cmd ;; extracted from executable... SET WebStormIconPath=d:\dev\apps\jetbrains\shell-scripts\webstorm.ico echo Adding file entries @reg add "HKEY_CLASSES_ROOT\*\shell\WebStorm" /t REG_SZ /v "" /d "Open with WebStorm" /f @reg add "HKEY_CLASSES_ROOT\*\shell\WebStorm" /t REG_EXPAND_SZ /v "Icon" /d "%WebStormIconPath%,0" /f @reg add "HKEY_CLASSES_ROOT\*\shell\WebStorm\command" /t REG_SZ /v "" /d "%WebStormPath% \"%%1\"" /f echo Adding within a folder entries @reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\WebStorm" /t REG_SZ /v "" /d "Open with WebStorm" /f @reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\WebStorm" /t REG_EXPAND_SZ /v "Icon" /d "%WebStormIconPath%,0" /f @reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\WebStorm\command" /t REG_SZ /v "" /d "%WebStormPath% \"%%V\"" /f echo Adding folder entries @reg add "HKEY_CLASSES_ROOT\Directory\shell\WebStorm" /t REG_SZ /v "" /d "Open with WebStorm" /f @reg add "HKEY_CLASSES_ROOT\Directory\shell\WebStorm" /t REG_EXPAND_SZ /v "Icon" /d "%WebStormIconPath%,0" /f @reg add "HKEY_CLASSES_ROOT\Directory\shell\WebStorm\command" /t REG_SZ /v "" /d "%WebStormPath% \"%%1\"" /f pause
Version PhpStorm
@echo off :: change the path below to match your installed version SET PhpStormPath=C:\Users\MyUser\AppData\Local\JetBrains\Toolbox\apps\PhpStorm.cmd ;; extracted from executable... SET PhpStormIconPath=C:\Users\MyUser\AppData\Local\JetBrains\Toolbox\apps\phpstorm.ico echo Adding file entries @reg add "HKEY_CLASSES_ROOT\*\shell\PhpStorm" /t REG_SZ /v "" /d "Open with PhpStorm" /f @reg add "HKEY_CLASSES_ROOT\*\shell\PhpStorm" /t REG_EXPAND_SZ /v "Icon" /d "%PhpStormIconPath%,0" /f @reg add "HKEY_CLASSES_ROOT\*\shell\PhpStorm\command" /t REG_SZ /v "" /d "%PhpStormPath% \"%%1\"" /f echo Adding within a folder entries @reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\PhpStorm" /t REG_SZ /v "" /d "Open with PhpStorm" /f @reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\PhpStorm" /t REG_EXPAND_SZ /v "Icon" /d "%PhpStormIconPath%,0" /f @reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\PhpStorm\command" /t REG_SZ /v "" /d "%PhpStormPath% \"%%V\"" /f echo Adding folder entries @reg add "HKEY_CLASSES_ROOT\Directory\shell\PhpStorm" /t REG_SZ /v "" /d "Open with PhpStorm" /f @reg add "HKEY_CLASSES_ROOT\Directory\shell\PhpStorm" /t REG_EXPAND_SZ /v "Icon" /d "%PhpStormIconPath%,0" /f @reg add "HKEY_CLASSES_ROOT\Directory\shell\PhpStorm\command" /t REG_SZ /v "" /d "%PhpStormPath% \"%%1\"" /f pause
Update: I've written a much improved PowerShell script to do this automatically, see https://gist.github.com/jcwillox/a9b480f8d180d44368e7df2eb7009207.
Here's a slightly modified version where you can enter the app name, this will work for any IDE just edit LaunchPath
, IconPath
and AppName
to reflect the IDE you're adding 👍.
Also if you're running toolbox and have nircmd
installed then you can use LaunchPath=nircmd execmd pycharm.cmd
to stop the command prompt window popping up briefly.
For clarity, this script adds an "Edit with MyIDE
" option for files (this will work with the new edit mode for files) and an "Open with MyIDE
" option for folders.
Adding the Context Menu:
@echo off
:: Needs to be run as administrator.
:: Change the paths below to match the desired IDE.
:: Make sure you don't quote any of the paths in following lines, spaces are allowed.
SET LaunchPath=C:\Users\MyUser\AppData\Local\JetBrains\Scripts\pycharm.cmd
SET IconPath=C:\Users\MyUser\AppData\Local\JetBrains\Scripts\icons\pycharm.ico
SET AppName=PyCharm
echo Adding file entries
@reg add "HKEY_CLASSES_ROOT\*\shell\%AppName%" /t REG_SZ /v "" /d "Edit with %AppName%" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\%AppName%" /t REG_EXPAND_SZ /v "Icon" /d "%IconPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\%AppName%\command" /t REG_SZ /v "" /d "%LaunchPath% \"%%1\"" /f
echo Adding within a folder entries
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\%AppName%" /t REG_SZ /v "" /d "Open with %AppName%" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\%AppName%" /t REG_EXPAND_SZ /v "Icon" /d "%IconPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\%AppName%\command" /t REG_SZ /v "" /d "%LaunchPath% \"%%V\"" /f
echo Adding folder entries
@reg add "HKEY_CLASSES_ROOT\Directory\shell\%AppName%" /t REG_SZ /v "" /d "Open with %AppName%" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\%AppName%" /t REG_EXPAND_SZ /v "Icon" /d "%IconPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\%AppName%\command" /t REG_SZ /v "" /d "%LaunchPath% \"%%1\"" /f
pause
Removing the Context Menu:
@echo off
:: Needs to be run as administrator.
:: Make sure you don't quote the name, spaces are allowed.
SET AppName=PyCharm
echo Deleting file entries
@reg delete "HKEY_CLASSES_ROOT\*\shell\%AppName%"
echo Deleting within a folder entries
@reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\%AppName%"
echo Deleting folder entries
@reg delete "HKEY_CLASSES_ROOT\Directory\shell\%AppName%"
pause
Thank you very much
Oh my god, thank you very much you are a god! 😄
thanks a lot! very helpful 💖
@jcwillox thanks a lot. Ever since I started using JetBrains' toolbox, the context menu thing disappeared. Your script really helps.
good
How I can disable it?
So, I got around to improving my personal script and have published it now over at https://gist.github.com/jcwillox/a9b480f8d180d44368e7df2eb7009207.
It's a PowerShell script that can automatically create the context menus, all you need is to give it the names of the IDEs you want context menus for, it also handles removing them, and has an option to use nircmd
so the context menus don't need to be updated each time you update an IDE. Overall, it should be a lot more robust and easier to use than the batch scripts I posted before.
@jcwillox I am having trouble running this, keep getting errors relating to arguments being null when trying to run your example commands.
So it seems to be failing while trying to list items in the toolbox directory, can you check you have toolbox installed and that C:\Users\<username>\AppData\Local\JetBrains\Toolbox\apps
exists? If it does exist what files/folders are present in that directory?
@jcwillox sorry the response took so long, this appears to happen no matter what command I run just for reference.
All good I went to sleep after that. That's is quite odd, this seems to be the fragment that is failing, so you can try running that
foreach ($item in (Get-ChildItem (Join-Path $env:LOCALAPPDATA "JetBrains\Toolbox\apps") -Exclude Toolbox)) {
Get-ChildItem -Path (Join-Path $item.FullName "ch-0") -Directory -Exclude "*.plugins"
}
it seems like the full name property is missing so maybe try just printing that
foreach ($item in (Get-ChildItem (Join-Path $env:LOCALAPPDATA "JetBrains\Toolbox\apps") -Exclude Toolbox)) {
$item.FullName
}
Thank You for the help
Ok, so I think I figured out what's happening or at least will be able to tell now. Basically, PowerShell was being stupid and giving an almost useless error message. It will now give the proper error message, but I think it's failing to find the version / correct version folder.
Try downloading and running the latest version of the script, I also added some verbose logging so give .\toolbox-context-menu.ps1 -List -Verbose
a try. To be clear it still has the same issue but just has the ability to tell me whats actually wrong.
Sorry for not replying to @Townsy45 for so long.
Just an update for anyone following the problem identified above, it has now been fixed and the script has been updated.
It's probably best to keep discussion of issues related to my PowerShell script over on its own gist.
If you only need to add a right-click menu to the file, you can use a simple registry to replace the installation path with your own, paying attention to path escaping.
Create a WebStorm.reg
file, copy the code, and double-click to run it.
Windows Registry Editor Version 5.00
; Open files
[HKEY_CLASSES_ROOT\*\shell\WebStorm]
@="Open with WebStorm"
"Icon"="C:\\Program Files\\JetBrains\\WebStorm 2022.1\\bin\\webstorm64.exe,0"
[HKEY_CLASSES_ROOT\*\shell\WebStorm\command]
@="\"C:\\Program Files\\JetBrains\\WebStorm 2022.1\\bin\\webstorm64.exe\" \"%1\""
Thank you very much!)))))
Greatly appreciate it!
Спасибо! Thank u
thank you very much, still working!
tried on windows 10
Thank you, still works at windows 11!
Still works win11 Pro
I use this dirty hack to get the latest installed version of PHPStorm in "Program Files" (instead of giving the exact version in the script) :
set "PhpStormPath="
for /d %%A in ("C:\Program Files\JetBrains\PhpStorm*") do (
set "PhpStormPath=%%~fA"
)
This is something that was incorporated in the core of the Intellej familty of products so I don't think this thread is relevant any longer
I use this dirty hack to get the latest installed version of PHPStorm in "Program Files" (instead of giving the exact version in the script) :
set "PhpStormPath=" for /d %%A in ("C:\Program Files\JetBrains\PhpStorm*") do ( set "PhpStormPath=%%~fA" )
You don't have to do any of that if you use the JetBrains Toolbox App.
This is something that was incorporated in the core of the Intellej familty of products so I don't think this thread is relevant any longer
Pretty sure there's no Explorer integration for directories yet.
same here