Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set value in registry via batch file in Windows?

I am going to set a value to windows registry. I want to set variable shit for StupidMS in registry, but the result is wrong. Following is my code.

set stupidMS=shit
echo %stupidMS% 

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v "StupidMS" /t REG_SZ /d ^%stupidMS^%

I think the problem is ^%stupidMS^%, but I quite have no idea how to correct it.

like image 471
CCC Avatar asked Jul 18 '13 04:07

CCC


People also ask

How do I change the value of data in the registry?

To rename a registry value, right-click or tap-and-hold on the value on the right and choose Rename. Give the registry value a new name and then press Enter. To change a value's data, right-click or tap-and-hold on the value on the right and choose Modify.... Assign a new Value data and then confirm with the OK button.


1 Answers

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v "StupidMS" /t REG_SZ /d "%stupidMS%"
like image 65
CCC Avatar answered Oct 13 '22 11:10

CCC