Using regedit /s
is possible, but a little awkward, since you'd have to create a file with the settings and then import that file. And even if we ignored that, the solution still had the problem that regedit
doesn't return a status code indicating whether the import was successful or not. The latter could be addressed by replacing regedit.exe
with reg.exe
:
rc = objShell.Run("reg import \\host\share\registry.reg", 0, True)
However, it's unnecessary to import an external file. VBScript can directly create, manipulate and delete registry keys and values, either via a WshShell
object:
Set sh = CreateObject("WScript.Shell")
sh.RegDelete "HKLM\SOFTWARE\Policies\Skype\Phone\ProxySetting"
sh.RegDelete "HKLM\SOFTWARE\Policies\Skype\Phone\ProxyAddress"
sh.RegDelete "HKLM\SOFTWARE\Policies\Skype\Phone\DisableUDP"
or via WMI:
Const HKLM = &h80000001
Const key = "SOFTWARE\Policies\Skype\Phone"
Set reg = GetObject("winmgmts://./root/default:StdRegProv")
rc1 = reg.DeleteValue(HKLM, key, "ProxySetting")
rc2 = reg.DeleteValue(HKLM, key, "ProxyAddress")
rc3 = reg.DeleteValue(HKLM, key, "DisableUDP")