更新: 我能够使用/ RL选项执行最高权限作业。 (但仍然想知道为什么官方微软文档中没有提到这一点?)
正如标题所说,我想创建一个具有修改功率条件的计划任务(仅在插入ac时才会运行),因为我们可以在GUI模式下取消选项,在Windows 8.1中批处理文件/命令提示符的帮助。
我用过:
schtasks /create /sc minute /tn test1 /tr "C:\Users\SOURAV\Desktop\beautiful_text.bat" /mo 1 /ru ""
它创建了计划任务但没有最高权限。此外还有一些限制,例如只有在插入交流电源时才能执行任务。等
我的问题是如何通过命令提示符来实现与GUI相同的功能?
stackoverflow中的另一个答案表示,不可能像在GUI中那样通过命令提示符来实现所有任务。但是我看到Opera浏览器/ Google驱动器在任务调度程序中自动创建了计划任务,并且它们的任务以最高权限运行。 [见下图链接] http://i.stack.imgur.com/UAu7I.png
有谁可以解释所有这些事情? 谢谢。 :)
答案 0 :(得分:3)
导出为XML文件或使用echo即时创建。
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2012-08-19T16:49:14.6182</Date>
<Author>Serenity\David Candy</Author>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2012-08-19T04:30:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByWeek>
<DaysOfWeek>
<Monday />
<Tuesday />
<Wednesday />
<Thursday />
<Friday />
</DaysOfWeek>
<WeeksInterval>1</WeeksInterval>
</ScheduleByWeek>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>SERENITY\David Candy</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<IdleSettings>
<Duration>PT10M</Duration>
<WaitTimeout>PT1H</WaitTimeout>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>true</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>"C:\Program Files\Windows Media Player\wmplayer.exe"</Command>
<Arguments>"C:\Users\David Candy\Documents\Music\Soundtrack\Natural Born Killers [Original Soundtrack]\13 Sex Is Violent.wma"</Arguments>
</Exec>
<SendEmail>
<Server>pop.gmail.com</Server>
<Subject>Hi</Subject>
<To>Fred</To>
<From>DCandy</From>
<Body>Hello</Body>
<HeaderFields />
</SendEmail>
</Actions>
</Task>
来自schtasks /create /?
的帮助
/XML xmlfile Creates a task from the task XML specified in a file.
Can be combined with /RU and /RP switches, or with /RP
alone, when task XML already contains the principal.
答案 1 :(得分:3)
这是如何将一个xml文件放在一个bat文件中。注意Skip = 6表示xml文件必须从第7行开始。
FOR /F "usebackq skip=6 delims=" %%i IN (%0) DO @echo %%i >>"%temp%\tmp010.xml"
notepad "%temp%\tmp010.xml"
del "%temp%\tmp010.xml"
goto :eof
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2012-08-19T16:49:14.6182</Date>
<Author>Serenity\David Candy</Author>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2012-08-19T04:30:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByWeek>
<DaysOfWeek>
<Monday />
<Tuesday />
<Wednesday />
<Thursday />
<Friday />
</DaysOfWeek>
<WeeksInterval>1</WeeksInterval>
</ScheduleByWeek>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>SERENITY\David Candy</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<IdleSettings>
<Duration>PT10M</Duration>
<WaitTimeout>PT1H</WaitTimeout>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>true</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>"C:\Program Files\Windows Media Player\wmplayer.exe"</Command>
<Arguments>"C:\Users\David Candy\Documents\Music\Soundtrack\Natural Born Killers [Original Soundtrack]\13 Sex Is Violent.wma"</Arguments>
</Exec>
<SendEmail>
<Server>pop.gmail.com</Server>
<Subject>Hi</Subject>
<To>Fred</To>
<From>DCandy</From>
<Body>Hello</Body>
<HeaderFields />
</SendEmail>
</Actions>
</Task>