When running a VBS script by double clicking on the script file, the code does not run as an elevated user.
There are several workarounds to this, such as –
- using the ‘runas’ command,
- opening an elevated command prompt then calling the script using cscript,
- or disabling the User Access Control feature.
However these workarounds are time consuming when compared to simply double clicking to run.
To fix this issue you can add the following code to your existing VBS script. Just place your script between ‘Start of code’ and ‘End of code’
Full Download: Here
Run VBS As Elivated User -Win7.vbs
'-------------- 'Start of UAC workaround code If WScript.Arguments.length =0 Then Set objShell = CreateObject("Shell.Application") objShell.ShellExecute "wscript.exe", Chr(34) & _ WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1 Else '-------------- 'Start of code WScript.Echo "This code is ran as an elevated user, ie. 'Administrator'" '-------------- 'End of code '-------------- 'End of UAC workaround code End If