Add registry key entries using batch file

5

2

How to add the below keys using pure batch file?

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Server]
"DisplayName"="Server"
"DisplayVersion"="1.2"
"InstallLocation"="C:\\Program Files\\1.2"
"NoModify"=dword:00000001
"Publisher"="ABC"
"UninstallPath"="D:\\test\\Uninstall.bat"
"UninstallString"="D:\\test\\Uninstall.bat"

Senthil

Posted 2014-05-31T10:52:38.580

Reputation: 51

Question was closed 2014-06-01T09:58:54.100

Answers

10

The following lines will add the registry entries you are asking for.

reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Server" /v DisplayName /t REG_SZ /d Server
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Server" /v DisplayVersion /t REG_SZ /d 1.2
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Server" /v InstallLocation /t REG_SZ /d C:\\Program Files\\1.2
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Server" /v NoModify /t REG_DWORD /d 1
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Server" /v Publisher /t REG_SZ /d ABC
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Server" /v UninstallPath /t REG_SZ /d D:\\test\\Uninstall.bat
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Server" /v UninstallString /t REG_SZ /d D:\\test\\Uninstall.bat

Ĭsααc tիε βöss

Posted 2014-05-31T10:52:38.580

Reputation: 1 772

4

I'm not in front of a Windows machine right now. A .reg file would be most appropriate, as that can automatically add and remove keys. But you want a batch file.

You could do a list of lines of the form reg add .......

The reg command can add a key.

C:\>reg add /? shows for example

REG ADD HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d fax\0mail
  Adds a value (name: MRU, type: REG_MULTI_SZ, data: fax\0mail\0\0)

barlop

Posted 2014-05-31T10:52:38.580

Reputation: 18 677

also if you open regedit and right click in the right hand pane and do 'new' you can see a list of types. – barlop – 2014-05-31T11:04:19.623

2The main advantages of reg over regedit + .reg file is reg can be scripted (IIRC .reg requires interactive confirmation of the popup) and reg doesn't require elevation, so no UAC popup if you're only editing your user's registry hives. – Bob – 2014-05-31T11:19:37.287

2

Documentation of REG ADD command http://technet.microsoft.com/en-us/library/cc742162.aspx

– David Marshall – 2014-05-31T11:21:23.770

two links that might help re terminology (key,name,value,data). and 'hive'(a root key) http://pcsupport.about.com/od/termsr/g/registryhive.htm http://en.wikipedia.org/wiki/Windows_Registry

– barlop – 2014-05-31T11:29:37.120