我正在开发一个简单的JScript脚本,由Windows Script Host运行。
此脚本需要读取任务计划程序中的一些数据。我不知道该怎么开始。
我已经在c++中使用任务调度器2.0接口实现了类似的功能
我可以在JScript中以某种方式使用这些接口吗?
发布于 2015-08-26 07:30:30
不,不能使用来自JScript的TaskScheduler2.0接口。
但是,您可以读取任务调度程序创建的XML文件。它们包含所有定义任务的所有属性。
它们驻留在%windir%\system32\tasks中(需要管理员权限来读取该目录及其内容)。
下面是这样一个文件的示例,它是非常简单的XML:
<Task version="1.1" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Author>SYSTEM</Author>
<Description>Some text here...</Description>
</RegistrationInfo>
<Triggers>
<LogonTrigger>
<Enabled>true</Enabled>
</LogonTrigger>
<CalendarTrigger>
<Enabled>true</Enabled>
<StartBoundary>2015-07-16T05:32:00</StartBoundary>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Settings>
<Enabled>true</Enabled>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<Hidden>false</Hidden>
<WakeToRun>false</WakeToRun>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<Priority>5</Priority>
<IdleSettings>
<Duration>PT600S</Duration>
<WaitTimeout>PT3600S</WaitTimeout>
<StopOnIdleEnd>false</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
</Settings>
<Principals>
<Principal id="Author">
<UserId>System</UserId>
<RunLevel>HighestAvailable</RunLevel>
<LogonType>InteractiveTokenOrPassword</LogonType>
</Principal>
</Principals>
<Actions Context="Author">
<Exec>
<Command>C:\path\to\executable.exe</Command>
<Arguments>/args</Arguments>
</Exec>
</Actions>
</Task>要找出的事情清单:
PT600S这样的值。幸运的是,对于所有这些事情,有很多例子(在这个站点和其他地方)可以帮助您入门。
https://stackoverflow.com/questions/32220258
复制相似问题