Skip to content

Instantly share code, notes, and snippets.

@M1chaelTran
Created August 17, 2017 11:04
Show Gist options
  • Star 79 You must be signed in to star a gist
  • Fork 16 You must be signed in to fork a gist
  • Save M1chaelTran/f22ac7c48466e8970f932ab743043e79 to your computer and use it in GitHub Desktop.
Save M1chaelTran/f22ac7c48466e8970f932ab743043e79 to your computer and use it in GitHub Desktop.
Add `Open with WebStorm` to Windows right click context menu
@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
@KulaGGin
Copy link

Made for PhpStorm one too:

@echo off

SET PhpStormPath=D:\Programs\JetBrains\PhpStorm 2018.1.6\bin\PhpStorm64.exe
 
echo Adding file entries
@reg add "HKEY_CLASSES_ROOT\*\shell\PhpStorm" /t REG_SZ /v "" /d "Open in PhpStorm"   /f
@reg add "HKEY_CLASSES_ROOT\*\shell\PhpStorm" /t REG_EXPAND_SZ /v "Icon" /d "%PhpStormPath%,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 "%PhpStormPath%,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 "%PhpStormPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\PhpStorm\command" /t REG_SZ /v "" /d "%PhpStormPath% \"%%1\"" /f

Gist link

@AndrewBogdanovTSS
Copy link

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?

@mantasaudickas
Copy link

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

@adir1661
Copy link

Worked for me, successful added to context menu. Only problem: If im useing the Open with.. function, Webstorm then displays an error. 'Cannot find file...'

same here

@fend25
Copy link

fend25 commented Sep 24, 2019

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

@daom89
Copy link

daom89 commented Apr 19, 2020

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

@jcwillox
Copy link

jcwillox commented Apr 27, 2020

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

@PutK
Copy link

PutK commented Jul 1, 2020

Thank you very much

@Townsy45
Copy link

Oh my god, thank you very much you are a god! 😄

@obenchkroune
Copy link

thanks a lot! very helpful 💖

@shepardm7
Copy link

@jcwillox thanks a lot. Ever since I started using JetBrains' toolbox, the context menu thing disappeared. Your script really helps.

@mraiguo
Copy link

mraiguo commented Jul 6, 2021

good

@wonder-wafflen
Copy link

How I can disable it?

@jcwillox
Copy link

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.

@Townsy45
Copy link

Townsy45 commented Feb 1, 2022

@jcwillox I am having trouble running this, keep getting errors relating to arguments being null when trying to run your example commands.

image

@jcwillox
Copy link

jcwillox commented Feb 1, 2022

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?

@Townsy45
Copy link

Townsy45 commented Feb 1, 2022

@jcwillox sorry the response took so long, this appears to happen no matter what command I run just for reference.

Also the path exists and these are the folders in there:
image

@jcwillox
Copy link

jcwillox commented Feb 2, 2022

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
}

@Townsy45
Copy link

Townsy45 commented Feb 2, 2022

@jcwillox they both work and return paths 🤷

image

image

@kumaran-IV0IV
Copy link

Thank You for the help

@ntwi
Copy link

ntwi commented Mar 31, 2022

@jcwillox I am having trouble running this, keep getting errors relating to arguments being null when trying to run your example commands.

image

Same issue here, and running both scripts mentioned by @jcwillox here returns paths without issue.

@jcwillox
Copy link

jcwillox commented Apr 1, 2022

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.

@jcwillox
Copy link

jcwillox commented Apr 2, 2022

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.

@ouweiya
Copy link

ouweiya commented Apr 21, 2022

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\""

@Daniil-333
Copy link

Thank you very much!)))))

@CodeLikeAGirl29
Copy link

Greatly appreciate it!

@aychernov
Copy link

Спасибо! Thank u

@itsKnight847
Copy link

itsKnight847 commented Jul 20, 2023

thank you very much, still working!
tried on windows 10

@bagasdisini
Copy link

Thank you, still works at windows 11!

@derstine-buyagan-lmg
Copy link

Still works win11 Pro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment