VB script to delete key value then update it
script should work in 2 steps.
1) It should delete values in Browser and Client_Name under HKEY_LOCAL_MACHINE\SOFTWARE\Veritas\NetBackup\CurrentVersion\Config
2) It should update values in Browser and Client_Name as SERVERNAME under HKEY_LOCAL_MACHINE\SOFTWARE\Veritas\NetBackup\CurrentVersion\Config
I am a newbie in vbscript so need spoonfeeding at scripting level. Any help would be much appreciated.
You can use the RegRead,RegWrite,RegDelete methods of the WSCript.Shell object. For example:
Set WshShell = CreateObject("WScript.Shell")
SERVERNAME = "MYSERVER" WshShell.RegDelete "HKLM\SOFTWARE\Veritas\NetBackup\CurrentVersion\Config\Browser"
WshShell.RegDelete "HKLM\SOFTWARE\Veritas\NetBackup\CurrentVersion\Config\Client_Name" myKey = "HKLM\SOFTWARE\Veritas\NetBackup\CurrentVersion\Config\"
WshShell.RegWrite myKey & "Browser",SERVERNAME,"REG_SZ"
WshShell.RegWrite myKey & "Client_Name",SERVERNAME,"REG_SZ" Set WshShell = Nothing
Really, though, there's no need to use the RegDelete, as the RegWrite will overwrite the value. You could also include a RegRead to verify whether or not the values are already up to date