Skip to content

Instantly share code, notes, and snippets.

@M1chaelTran
Created August 17, 2017 11:04
Show Gist options
  • Select an option

  • Save M1chaelTran/f22ac7c48466e8970f932ab743043e79 to your computer and use it in GitHub Desktop.

Select an option

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
@fend25

fend25 commented Sep 24, 2019

Copy link
Copy Markdown

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

daom89 commented Apr 19, 2020

Copy link
Copy Markdown

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

jcwillox commented Apr 27, 2020

Copy link
Copy Markdown

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

PutK commented Jul 1, 2020

Copy link
Copy Markdown

Thank you very much

@Townsy45

Copy link
Copy Markdown

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

@obenchkroune

Copy link
Copy Markdown

thanks a lot! very helpful 💖

@shepardm7

Copy link
Copy Markdown

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

@mraiguo

mraiguo commented Jul 6, 2021

Copy link
Copy Markdown

good

@4s-ary

4s-ary commented Dec 11, 2021

Copy link
Copy Markdown

How I can disable it?

@jcwillox

Copy link
Copy Markdown

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

Townsy45 commented Feb 1, 2022

Copy link
Copy Markdown

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

image

@jcwillox

jcwillox commented Feb 1, 2022

Copy link
Copy Markdown

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

Townsy45 commented Feb 1, 2022

Copy link
Copy Markdown

@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

jcwillox commented Feb 2, 2022

Copy link
Copy Markdown

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

Townsy45 commented Feb 2, 2022

Copy link
Copy Markdown

@jcwillox they both work and return paths 🤷

image

image

@kumaran-IV0IV

Copy link
Copy Markdown

Thank You for the help

@ntwi

ntwi commented Mar 31, 2022

Copy link
Copy Markdown

@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

jcwillox commented Apr 1, 2022

Copy link
Copy Markdown

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

jcwillox commented Apr 2, 2022

Copy link
Copy Markdown

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

ouweiya commented Apr 21, 2022

Copy link
Copy Markdown

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
Copy Markdown

Thank you very much!)))))

@CodeLikeAGirl29

Copy link
Copy Markdown

Greatly appreciate it!

@aychernov

Copy link
Copy Markdown

Спасибо! Thank u

@Guthix2827

Guthix2827 commented Jul 20, 2023

Copy link
Copy Markdown

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

@bagasdisini

Copy link
Copy Markdown

Thank you, still works at windows 11!

@derstine-buyagan-lmg

Copy link
Copy Markdown

Still works win11 Pro

@Worst45

Worst45 commented May 6, 2024

Copy link
Copy Markdown

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

@AndrewBogdanovTSS

Copy link
Copy Markdown

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

@m4heshd

m4heshd commented May 6, 2024

Copy link
Copy Markdown

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.

@rklec

rklec commented Feb 23, 2026

Copy link
Copy Markdown

BTW the IntelliJ installer has an option to do it directly. However if installed via toolbox this does not work anymore, see TBX-2540 (jetbrains.com) TBX-2478 (jetbrains.com). A workaround is a community tool provided in https://github.com/246859/AutoToolBox/blob/main/README.en.md

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