views:

4840

answers:

9

Is it possible to modify a registry value (whether string or DWORD) via a .bat/.cmd script?

+8  A: 

You can use the REG command (http://www.ss64.com/nt/reg.html)

Rui Vieira
+2  A: 

You can make a .reg file and call start on it. You can export any part of the registry as a .reg file to see what the format is.

Format here:

http://support.microsoft.com/kb/310516

This can be run on any Windows machine without installing other software.

Lou Franco
+7  A: 

Yes, you can script using the reg command. Example:

reg add HKCU\Software\SomeProduct
reg add HKCU\Software\SomeProduct /v Version /t REG_SZ /d v2.4.6

This would create key HKEY_CURRENT_USER\Software\SomeProduct, and add a String value "v2.4.6" named "Version" to that key.

reg /? has the details.

Factor Mystic
A: 

Yes. You can use reg.exe which comes with the OS to add, delete or query registry values. Reg.exe does not have an explicit modify command, but you can do it by doing delete and then add.

Franci Penov
A: 

In addition to reg.exe, I highly recommend that you also check out powershell, its vastly more capable in its registry handling.

Tim Jarvis
A: 

@Franci Penov - modify is possible in the sence of overwrite with `/f, eg

reg add "HKCU\Software\etc\etc" /v "value" /t REG_SZ /d "Yes" /f
nray
A: 

I want to add that script on other PC form server... how ?

thanks ez@z

A: 

i wnat a add string value in [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]

birublone