Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Triavanicus/33081324b96f0111282bf365f1b1dd22 to your computer and use it in GitHub Desktop.
Save Triavanicus/33081324b96f0111282bf365f1b1dd22 to your computer and use it in GitHub Desktop.
@echo off
set context=%1
set app_name=%~2
set app_title=%~3
set app_icon=%~4
set app=%~5
set arguments=%~6
set location=HKEY_CLASSES_ROOT
set var=%%V\
if /I %context%==File (
set location=%location%\*\shell\%app_name%
set var=%%1
) else if /I %context%==Directory (
set location=%location%\Directory\shell\%app_name%
) else if /I %context%==DirectoryBackground (
set location=%location%\Directory\Background\shell\%app_name%
) else if /I %context%==Drive (
set location=%location%\Drive\shell\%app_name%
) else (
echo Available context menus are File, Directory, DirectoryBackground, and Drive
echo.
echo usage:
echo %0 [Context] [ApplicationName] ["Title"] ["Icon"] ["Executable"] ["Arguments"]
echo.
echo Note with arguments, if you need to specify file or directory do it last
echo.
echo Examples:
echo %0 File MyApp "Edit with My^&App" "C:\path to\my app.exe" "C:/path to/my app.exe"
echo %0 DirectoryBackground MyApp "Edit with My^&App" C:\path\to\my_app.exe C:\path\to\my_app.exe
echo %0 File MyApp "Edit with My^&App" "C:/path to/my app.exe" "C:/path to/my app.exe"
exit
)
REG Add "%location%" /f /ve /t REG_EXPAND_SZ /d "%app_title%"
REG Add "%location%" /f /v Icon /t REG_EXPAND_SZ /d "%app_icon%"
REG Add "%location%\Command" /f /ve /t REG_EXPAND_SZ /d "\"%app%\" %arguments% \"%var%\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment