schtasks SYSTEM fails

岁酱吖の 提交于 2019-12-12 01:34:00

问题


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.


回答1:


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.

It also runs using

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



回答2:


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.



来源:https://stackoverflow.com/questions/14391774/schtasks-system-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!