Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Run As Admin RunAs Administrator WinBatch WBT Script UAC Scheduler Schedule Task Interactive
The trick is to use the Task Scheduler. Note: you must be an Administor in order to create the scheduled task.:
Keep in mind that the task scheduler runs all scripts in non-interactive mode. So you will need to make sure that your script doesn't attempt to display anything or interact with any desktop windows ( Sendkey or Mouse ). You will also want to make sure the script runs quietly ( doesn't display any messages or error messages). Simply add IntControl(38,1,DirScript():'wberrorlog.txt',0,0) to the beginning of the script to make sure it runs in quiet mode.
Possible interactive mode workaround The fix is to create your Scheduled Task in interactive mode. Unfortunately you cannot do this through the GUI; it must be done through the command line. You can use the following command to create a new interactive scheduled task:
useracct = 'domain\user' taskname = 'Run as admin WBT' wbtscript = 'c:\temp\sample.wbt' ShellExecute( 'schtasks', '/Create /RU "':useracct:'" /SC ONLOGON /TN "':taskname:'" /TR "':wbtscript:'" /IT /V1', '', @NORMAL, '')The /IT switch is what tells it to create the task in Interactive mode. The /V1 switch actually specifies to create the task as a Windows XP/2000/Server 2003 compatible task, and has the added benefit of making the task run as admin by default with the Start In directory specified as the directory holding the file to run.
Article ID: W18318
Filename: Run As Admin WinBatch Script With UAC On.txt
File Created: 2013:11:13:10:27:18
Last Updated: 2013:11:13:10:27:18