I have the following reg file
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Run script]
@="Run &script"
[HKEY_CLASSES_ROOT\*\shell\Run script\command]
@="\"C:\\Users\\teodora\\Desktop\\test.bat\" \"%1\""
How can I add the path of the current folder instead of using C:\Users... ? I know how to do this in a .bat file but for a .reg one doesn't work in the same way.
You don't use a reg file, you use reg.exe
with the Add
option:
Here's a complete batch file which should do it all for you:
@Reg Add "HKCU\Software\Classes\*\Shell\RunScript" /VE /D "Run &Script" /F >Nul
@Reg Add "HKCU\Software\Classes\*\Shell\RunScript\command" /VE /D "\"%CD%\test.bat\" \"%%L\"" /F >Nul
Note that this uses the 'current directory' as requested. Adjust %CD%
accordingly if you no longer want that.
Use the variable %W
which is the working directory.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Run script]
@="Run &script"
[HKEY_CURRENT_USER\Software\Classes\*\shell\run script\command]
@="cmd /c \"\"%W\\test.bat\" \"%1\"\""
Using %W
instead of a literal absolute path seems to require cmd /c
as a prefix to work for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With