问题
The end of my VBScript (the rest is mainly WScript.Echo
reminders) looks like this (launches X-Plane, maximized):
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""X:\X-Plane\X-Plane.exe"""), 3
Set objShell = Nothing
What would I need to add to this to get X-Plane to run as administrator? An hour's Googling has got me nowhere!
回答1:
Provided you have UAC enabled and your user is a member of the Administrators group you can use the ShellExecute method with the "runas" verb:
Set app = CreateObject("Shell.Application")
app.ShellExecute "X:\X-Plane\X-Plane.exe", , , "runas", 3
来源:https://stackoverflow.com/questions/46267758/how-to-have-vbs-launch-a-program-as-administrator