6

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
  • 61
  • 1
  • 1
  • 2

2 Answers2

11

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
Mokubai
  • 89,133
  • 25
  • 207
  • 233
Ĭsααc tիε βöss
  • 2,252
  • 1
  • 18
  • 25
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)
Run5k
  • 15,723
  • 24
  • 49
  • 63
barlop
  • 23,380
  • 43
  • 145
  • 225
  • also if you open regedit and right click in the right hand pane and do 'new' you can see a list of types. – barlop May 31 '14 at 11:04
  • 2
    The 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 May 31 '14 at 11:19
  • 2
    Documentation of REG ADD command http://technet.microsoft.com/en-us/library/cc742162.aspx – David Marshall May 31 '14 at 11:21
  • 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 May 31 '14 at 11:29