Reputation: 467
I want to change a registry value (a REG_DWORD), then run an application, by using a batch file, that is located in the same folder as the application. I tried the lines below, but that does not work:
reg add "HKEY_CURRENT_USER\A User Name\An Application Name" /v A value name_h3981298716 /d "99" /t REG_DWORD /f
START %~dp0AnApplicationName.exe
The "START ..." will work without the "reg add ..." code. The batch file can run an application, but it cannot change a registry value of REG_DWORD type.
How to do the sequence below correctly with a batch file?
First, change a registry value of REG_DWORD type.
Then run an application.
Upvotes: 0
Views: 1487
Reputation: 30103
reg add "HKCU\A User Name\An Application Name" /v "A value name_h3981298716" /d "99" /t REG_DWORD /f
Note that if a value name contains a space then it should be surrounded with double quotes. Keep doing that even if a value name does not contain any space.
Example, with another key name:
==> reg query "HKCU\Software\Test Key" /t reg_dword
End of search: 0 match(es) found.
==> reg add "HKCU\Software\Test Key" /v A value name_h3981298716 /d "99" /t REG_DWORD /f
ERROR: Invalid syntax.
Type "REG ADD /?" for usage.
==> reg add "HKCU\Software\Test Key" /v "A value name_h3981298716" /d "99" /t REG_DWORD /f
The operation completed successfully.
==> reg query "HKCU\Software\Test Key" /t reg_dword
HKEY_CURRENT_USER\Software\Test Key
A value name_h3981298716 REG_DWORD 0x63
End of search: 1 match(es) found.
Upvotes: 1