How to run VBScript as an administrator?
Posted on 2007-04-10
I'm a VBScript noob and could really use the collective's help. I have a VBScript that I downloaded from this website that runs at user logon through Windows group policy. Basically the script forces the user's computer to reregister itself with my Windows Software Update Server (WSUS). Users do not have administrator rights on the local workstation. What do I need to add to the script in order to have it run without admin rights? Or is there something that can be added that will run the script as an administrator? Here is the code:
Set oShell = CreateObject("WScript.Shell")
sRegKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate"
' suppress error in case values does not exist
On Error Resume Next
' check for marker
sIDDeleted = oShell.RegRead( sRegKey & "\IDDeleted")
' to be sure values is only deleted once, test on marker
If sIDDeleted <> "yes" Then
' delete values
oShell.RegDelete sRegKey & "\AccountDomainSid"
oShell.RegDelete sRegKey & "\PingID"
oShell.RegDelete sRegKey & "\SusClientId"
' Stop and start the Automatic updates service
oShell.Run "%SystemRoot%\system32\net.exe stop wuauserv", 0, True
oShell.Run "%SystemRoot%\system32\net.exe start wuauserv", 0, True
' Run wuauclt.exe with resetauthorization
sCmd = "%SystemRoot%\system32\wuauclt.exe /resetauthorization /detectnow"
oShell.Run sCmd, 0, True
' create marker
oShell.RegWrite sRegKey & "\IDDeleted", "yes"
Thanks for any and all help. It is greatly appreciated!