I have a script that I need to run as Administrator just as I would right click on cmd.exe and click Run As Administrator.
Currently this is what I have:
Call WSHShell.Run("cmd.exe /K netdom renamecomputer ... end code")
Step 1: Open the Command Prompt, and type the PowerShell as a command, then press Enter key. Step 2: Now, the command prompt will turn to Windows PowerShell. Step 3: Type the command start-process PowerShell -verb runas and press "enter" key. Step 4: It will bring up an elevated Windows PowerShell as an administrator.
Have you tried using ShellExecute?
RunCmdElevated.vbs
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "cmd.exe", "/k echo test", "", "runas", 1
wscript RunCmdElevated.vbs
gives
test
C:\Windows\system32>
in a new window. The "1" is the view mode
http://ss64.com/vb/shellexecute.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With