There is short description explaining the usage of the tool when it is ran with no arguments:
Code: Select all
Open the command identified by the menu over the folder.
run-here [/A] /I "menu" [/K iconfile] [/NO-CHECK] command [arguments]
run-here [/A] /U "menu"
run-here [/A] /S "menu"
menu The menu item of the Windows Explorer context menu.
command The command to be executed on selecting the menu.
arguments Arguments to be passed to the command (otherwise %V).
/A Apply for all users. By default, for the current user only.
/I Install the menu item.
/U Uninstall the existing item.
/S Show the Registry entries if they exist.
/K icon Set the menu icon.
/NO-CHECK Do not check the path to the command when installing.
Code: Select all
run-here /i "Run BusyBox Here" /k c:\PROGS\opt\busybox\busybox64.exe c:\PROGS\opt\busybox\busybox64.exe sh -c "cd '%V' ; sh"
Code: Select all
@echo off
setlocal
if /i "%~1" == "" goto :run_help
:: See also
:: https://www.howtogeek.com/165268/how-to-add-open-powershell-here-to-the-context-menu-in-windows/
:: https://www.tenforums.com/tutorials/60175-open-powershell-window-here-context-menu-add-windows-10-a.html
:: https://gist.github.com/davecan/f3045266aa9e3441211ab55f9db70c2b
:: Current user
:: HKEY_CURRENT_USER\Software\Classes\Drive\shell\<menu>\command
:: HKEY_CURRENT_USER\Software\Classes\Directory\shell\<menu>\command
:: HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\<menu>\command
set "run_rootkey=HKEY_CURRENT_USER"
:: All users
:: HKEY_LOCAL_MACHINE\Software\Classes\Drive\shell\<menu>\command
:: HKEY_LOCAL_MACHINE\Software\Classes\Directory\shell\<menu>\command
:: HKEY_LOCAL_MACHINE\Software\Classes\Directory\Background\shell\<menu>\command
if /i "%~1" == "/A" (
set "run_rootkey=HKEY_LOCAL_MACHINE"
shift
)
set "run_classkey=%run_rootkey%\Software\Classes"
:: /I, /U or /S
set "run_action=%~1"
shift
:: "menu"
set "run_menu=%~1"
shift
if not defined run_menu (
>&2 echo:Menu not declared
goto :run_help
)
if not "%run_menu%" == "%run_menu:\=%" (
>&2 echo:Incorrect menu: %run_menu%
goto :EOF
)
set "run_subkey_list=Drive Directory Directory\Background"
if /i "%run_action%" == "/I" goto :run_install
if /i "%run_action%" == "/U" goto :run_uninstall
if /i "%run_action%" == "/S" goto :run_show
>&2 echo:Unknown action: %run_action%
goto :run_help
:run_install
if /i "%run_menu%" == "cmd" goto :run_forbidden
:: [/K iconfile]
set "run_iconfile="
if /i "%~1" == "/K" (
set "run_iconfile=%~2"
shift
shift
)
:: [/NO-CHECK]
set "run_nocheck="
if /i "%~1" == "/NO-CHECK" (
set "run_nocheck=1"
shift
)
:: command
set "run_command=%~1"
shift
if not defined run_command (
>&2 echo:Command not specified
goto :run_help
)
if defined run_nocheck (
set "run_progpath=%run_command%"
goto :run_install_args
)
set "run_progpath="
for /f "tokens=*" %%c in ( "%run_command%" ) do (
if not "%%~$PATH:c" == "" set "run_progpath=%%~$PATH:c"
if exist "%%~fc" set "run_progpath=%%~fc"
)
if not defined run_progpath (
>&2 echo:Command not found: %run_command%
goto :run_help
)
:run_install_args
:: [arguments] or "%V"
set "run_arguments="
:run_install_args_begin
if "%~1" == "" goto :run_install_args_end
set "run_arguments=%run_arguments% %1"
shift
goto :run_install_args_begin
:run_install_args_end
:: http://superuser.com/a/473602
:: http://www.robvanderwoude.com/ntstart.php
:: http://msdn.microsoft.com/en-us/library/windows/desktop/cc144101%28v=vs.85%29.aspx
if not defined run_arguments set "run_arguments= "%%V""
:: Escape quotes before enclosing within quotes
set "run_arguments=%run_arguments:"=\"%"
for %%s in ( %run_subkey_list% ) do (
reg add "%run_classkey%\%%s\shell\%run_menu%\command" /ve /d "\"%run_progpath%\"%run_arguments%" /f
)
if defined run_iconfile for %%s in ( %run_subkey_list% ) do (
reg add "%run_classkey%\%%s\shell\%run_menu%" /v Icon /t REG_SZ /d "%run_iconfile%" /f
)
goto :EOF
:run_uninstall
if /i "%run_menu%" == "cmd" goto :run_forbidden
for %%s in ( %run_subkey_list% ) do (
reg delete "%run_classkey%\%%s\shell\%run_menu%" /f
)
goto :EOF
:run_show
for %%s in ( %run_subkey_list% ) do (
reg query "%run_classkey%\%%s\shell\%run_menu%" /s
)
goto :EOF
:run_forbidden
>&2 echo:the operation over this element is forbidden.
goto :EOF
:run_help
echo:Open the command identified by the menu over the folder.
echo:
echo:%~n0 [/A] /I "menu" [/K iconfile] [/NO-CHECK] command [arguments]
echo:%~n0 [/A] /U "menu"
echo:%~n0 [/A] /S "menu"
echo:
echo:menu The menu item of the Windows Explorer context menu.
echo:command The command to be executed on selecting the menu.
echo:arguments Arguments to be passed to the command (otherwise %%V).
echo:/A Apply for all users. By default, for the current user only.
echo:/I Install the menu item.
echo:/U Uninstall the existing item.
echo:/S Show the Registry entries if they exist.
echo:/K icon Set the menu icon.
echo:/NO-CHECK Do not check the path to the command when installing.
goto :EOF