I want to run a command from a DOS Prompt in Windows 7 from within WinBatch:
RunHidewait( Environment("COMSPEC"), '/c %Commands% >"%CommandRes%"')
This works fine for normal commands but some like NETSH reports "The requested operation requires elevation (Run as administrator)."
How do you launch a DOS Prompt with Run as administrator from WinBatch?
Thanks
Try ShellExecute with "RunAs" verb to launch your application as an Administrator
; You must be logged into a admin account for this wot work
ShellExecute(Environment("COMSPEC"), '/k Echo Test', '', @NORMAL, 'RunAs')
Exit
I have update my application (App2) to "HighestAvailable" setting so I can launch the CMD Prompt as Administrator without being asked if it is OK by Windows each time.
What I did not mention in my original Post is App2 gets launched by another WinBatch Application (App1).
Now when I Run App1 with the new version of App2 I get an error from this launching Application:
WinExec Error: The requested operation requires elevation. APP1 does not have sufficient elevation to run APP2 Use ShellExecute
If I change APP1 to use ShellExecute should I use the 'RunAs' switch when I call APP2?
Would it be better to also compile APP1 with HighestAvailable setting and if I do that do I need to change anything else when calling APP2?
Thanks