Question

It is noted here and in the help that you can set "run as".

/RU  username      Specifies the "run as" user account (user context)
                       under which the task runs. For the system account,
                       valid values are "", "NT AUTHORITY\SYSTEM"
                       or "SYSTEM".

From my tests these commands will start the task

schtasks /create /sc once /st 00:00 /f /tr foo.exe /tn bar
schtasks /run /i /tn bar

However running it as SYSTEM will not launch foo.exe

schtasks /create /sc once /st 00:00 /f /tr foo.exe /tn bar /ru SYSTEM
schtasks /run /i /tn bar

The reason I would like to run as SYSTEM is because it was said in the other question that doing so would essentially run foo.exe in the background without a window.

Was it helpful?

Solution

It works for me

C:\Windows\system32>schtasks /create /sc once /st 09:36 /f /tr notepad.exe /tn bar /ru SYSTEM
SUCCESS: The scheduled task "bar" has successfully been created.

enter image description here

It also runs using

C:\Windows\system32>schtasks /run /i /tn bar
SUCCESS: Attempted to run the scheduled task "bar".

OTHER TIPS

You have to run cmd.exe as an administrator then type in your code. Only an administrator can schedule a task to run as SYSTEM and a normal command line doesn't have enough privileges.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top