Windows 7 计划任务命令行

Windows 7 计划任务命令行

问题描述:

此命令应创建一个每分钟运行计算器 Windows 应用程序的任务.

This command should create a task that every minute runs the calculator windows application.

schtasks /Create /tn "mytask" /sc MINUTE /mo 1  /ru "myuser" /rp "mypassword" /tr "C:\Windows\System32\calc.exe"

它运行正常,任务被添加.任务看起来不错.任务在计划中显示为已开始,但计算器并未启动.exe存在,我可以单独运行.

It runs OK, the tasks gets added. The task looks right. The tasks shows as started in the schedular but the calculator does not get fired up. The exe exists, I can run it separately.

有人知道为什么我看不到计算器吗?

Anyone know why I don't see the calculator?

可能是因为任务没有以交互方式运行.添加/it"选项:

Probably because the task isn't running interactively. Add the '/it' option:

/IT
一个值,仅当/RU 用户当前已在任务运行时登录.任务仅在用户登录时运行.

/IT
A value that enables the task to run interactively only if the /RU user is currently logged on at the time the task runs. The task runs only if the user is logged on.

如果没有/it 选项,任务将在会话 0 中运行,这不允许与用户交互.有关详细信息,请在网络上搜索会话 0 隔离".

Without the /it option, tasks run in session 0, which doesn't allow interaction with the user. For more information, do a web search for "Session 0 isolation".