Sun*_*wal 5 windows scheduled-tasks schtasks.exe
我创建了一个Windows任务,并计划每1小时运行一次.
任务运行的每一个小时,但我都会收到警告,Task Scheduler did not launch task "\Sample Task" because computer is running on batteries. User Action: If launching the task on batteries is required, change the respective flag in the task configuration.并且任务会在成熟之前退出.
我正在使用SCHTASKS.exe创建任务,因为我需要创建从表单中获取用户输入的任务.
使用命令我想删除电源选项.
这可能吗?
Cod*_*ray 10
正如您可能已经观察到的那样,schtasks.exe 没有提供命令行开关来切换电源设置.
你基本上有两个解决方案:
您可以使用所需选项创建XML文件,然后从该XML文件在命令行上创建任务.
例如,您将在XML文件中包含以下settings元素:
<Settings>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
</Settings>
Run Code Online (Sandbox Code Playgroud)您可以编写将ITaskSettings::DisallowStartIfOnBatteries属性设置为所需值的代码.