Escalate Privileges in Windows 7

Windows 7 requires you to escalate privileges before running your VBSCript. The following script reopens the script with administration privileges.

If WScript.Arguments.length = 0 Then
Set objShell = CreateObject("Shell.Application")
' pass an argument with leading blank space (uac)
objShell.ShellExecute "wscript.exe", Chr(34) & _
WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
Else
' put your code here
End If
WScript.Quit

Leave a Reply