Skip to content

Instantly share code, notes, and snippets.

@amnuts
Last active June 22, 2021 17:04
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save amnuts/162f6b03c5f94692fd6c to your computer and use it in GitHub Desktop.
Save amnuts/162f6b03c5f94692fd6c to your computer and use it in GitHub Desktop.
Add context menu to Windows 7 to open file/folder in PhpStorm
@echo off
SET PhpStormPath=C:\Program Files (x86)\JetBrains\PhpStorm 8.0.2\bin\PhpStorm64.exe
echo Adding file entries
@reg add "HKEY_CLASSES_ROOT\*\shell\Open in PhpStorm" /t REG_SZ /v "" /d "Open in PhpStorm" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open in PhpStorm" /t REG_EXPAND_SZ /v "Icon" /d "%PhpStormPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open in PhpStorm\command" /t REG_SZ /v "" /d "%PhpStormPath% \"%%1\"" /f
echo Adding folder entries
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open directory in PhpStorm" /t REG_SZ /v "" /d "Open directory in PhpStorm" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open directory in PhpStorm" /t REG_EXPAND_SZ /v "Icon" /d "%PhpStormPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open directory in PhpStorm\command" /t REG_SZ /v "" /d "%PhpStormPath% \"%%1\"" /f
pause
@amnuts
Copy link
Author

amnuts commented Nov 21, 2014

Change PhpStormPath to whatever suits your system then right-click and 'run as administrator'.

@grovesdm
Copy link

This is awesome! Thank-you!!

@amnuts
Copy link
Author

amnuts commented Dec 11, 2015

You're welcome - thanks for the nice feedback :-)

@HackerChick
Copy link

Thank you thank you!

@georgetour
Copy link

Changed the path and works as supposed to in Windows 8.1.Thank you.

@jrab
Copy link

jrab commented Sep 20, 2016

Awesome this worked perfectly for WebStorm! Thanks!

@lmfresneda
Copy link

Thanks!!!!

@gilad905
Copy link

How can I undo this?
Thanks!

@amnuts
Copy link
Author

amnuts commented May 10, 2017

@gilad905 sorry, I didn't notice this comment at all and assume you have figure this out already. But to undo you simply have to delete the registry keys manually. Always recommended to back up your registry, though, before you make any changes to it!

@ToddHedrick
Copy link

You should also add in an entry to the directory background so you can right click inside a folder in an open space and open in PhpStorm

echo Adding folder entries
@reg add "HKEY_CLASSES_ROOT\Directory\Background\Open directory in PhpStorm" /t REG_SZ /v "" /d "Open directory in PhpStorm" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\Open directory in PhpStorm" /t REG_EXPAND_SZ /v "Icon" /d "%PhpStormPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\Open directory in PhpStorm\command" /t REG_SZ /v "" /d "%PhpStormPath% "%%1"" /f

@Leonardonline
Copy link

@ToddHedrick your suggestion, (really usefull !), won't work for me, other do!

@echo off

SET WebStormPath=<path_to_exe>

echo Adding file entries
@reg add "HKEY_CLASSES_ROOT*\shell\Open in WebStorm" /t REG_SZ /v "" /d "Open in WebStorm" /f
@reg add "HKEY_CLASSES_ROOT*\shell\Open in WebStorm" /t REG_EXPAND_SZ /v "Icon" /d "%WebStormPath%,0" /f
@reg add "HKEY_CLASSES_ROOT*\shell\Open in WebStorm\command" /t REG_SZ /v "" /d "%WebStormPath% "%%1"" /f

echo Adding folder entries
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open directory in WebStorm" /t REG_SZ /v "" /d "Open directory in WebStorm" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open directory in WebStorm" /t REG_EXPAND_SZ /v "Icon" /d "%WebStormPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open directory in WebStorm\command" /t REG_SZ /v "" /d "%WebStormPath% "%%1"" /f

echo Adding folder background
@reg add "HKEY_CLASSES_ROOT\Directory\Background\Open directory in WebStorm" /t REG_SZ /v "" /d "Open directory in WebStorm" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\Open directory in WebStorm" /t REG_EXPAND_SZ /v "Icon" /d "%WebStormPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\Open directory in WebStorm\command" /t REG_SZ /v "" /d "%WebStormPath% "%%1"" /f

pause

Any suggestions?

@dan-collins
Copy link

Not sure if you are still after this, but I think it wasn't working because it didn't include the shell. The following worked for me:

echo Adding folder backgrounds
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open directory in PhpStorm" /t REG_SZ /v "" /d "Open directory in PhpStorm"   /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open directory in PhpStorm" /t REG_EXPAND_SZ /v "Icon" /d "%PhpStormPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open directory in PhpStorm\command" /t REG_SZ /v "" /d "%PhpStormPath% \"%%1\"" /f```

@Shuunen
Copy link

Shuunen commented Jul 5, 2018

works great ! ❤️

@FawzyMokhtar
Copy link

Here is the one that works perfectly for me

  1. Create a file name it webstorm.bat
  2. Open file in any text editor
  3. Copy all text below from @echo off to pause and paste it in the file
  4. Consider replace the <Webstorm.exe path> with your webstorm.exe path
    for e.g

C:\Program Files\JetBrains\WebStorm 2017.2.2\bin\webstorm64.exe

  1. Save changes to the file
  2. Right click on the file then Run as Administrator
  3. Enjoy it!
@echo off

SET WebStormPath=<Webstorm.exe path>
 
echo Adding file entries
@reg add "HKEY_CLASSES_ROOT\*\shell\WebStorm" /t REG_SZ /v "" /d "Open w&ith 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 folder entries
@reg add "HKEY_CLASSES_ROOT\Directory\shell\WebStorm" /t REG_SZ /v "" /d "Open w&ith 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

echo Adding folder backgrounds
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\WebStorm" /t REG_SZ /v "" /d "Open w&ith 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

pause

@kosnet2
Copy link

kosnet2 commented Sep 6, 2018

Works in Windows 10 as well ! Thank you very much :)

@KulaGGin
Copy link

Here's a better version for PhpStorm:

@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

You can either click on a file, folder or if you're inside a folder - on empty space and open it in PhpStorm. It isn't mine, I just tweaked this gist that was intended for WebStorm image

@Luc45
Copy link

Luc45 commented Nov 1, 2018

@FawzyMokhtar thanks, worked nicely on Windows 10. (Just replaced the string "WebStorm" with "PHPStorm", similar to what KulaGGin did)

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