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")
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")
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
© 2022 - 2024 — McMap. All rights reserved.