【问题标题】:Script for finding scheduled task wizards task info用于查找计划任务向导任务信息的脚本
【发布时间】:2014-06-24 19:15:08
【问题描述】:

我知道有一个用于查找计算机计划任务的命令,但我想获取有关计划任务本身的更多信息。我想知道计划任务的执行时间和时间以及计划任务的名称和区域。有什么想法吗?

【问题讨论】:

  • 用于查找的相同命令还列出了属性。 schtasks /query /tn "Task Name" /v /fo list
  • @phd443322 效果很好,谢谢

标签: batch-file vbscript cmd


【解决方案1】:
Set TS = CreateObject("Schedule.Service")
TS.Connect("Serenity")

Set rootFolder = TS.GetFolder("\")

Set tasks = rootFolder.GetTasks(0)

If tasks.Count = 0 Then 
    Wscript.Echo "No tasks are registered."
Else
    WScript.Echo "Number of tasks registered: " & tasks.Count

    For Each Task In Tasks
    A=Task.Name
    A = A & " " & Task.NextRunTime
    wscript.echo A
    Next
End If

从帮助中,其中一些是包含其他信息的对象。

注册任务

提供用于立即运行任务、获取任何正在运行的任务实例、获取或设置用于注册任务的凭据以及描述任务的属性的方法的脚本对象。

方法 RegisteredTask 对象定义了以下方法。

Method Description 
GetInstances Returns all instances of the registered task that are currently running. 
GetSecurityDescriptor Gets the security descriptor that is used as credentials for the registered task. 
GetRunTimes Gets the times that the registered task is scheduled to run during a specified time. 
SetSecurityDescriptor Sets the security descriptor that is used as credentials for the registered task. 
RunEx Runs the registered task immediately using specified flags and a session identifier. 
Stop Stops the registered task immediately. 
Run Runs the registered task immediately. 

属性 RegisteredTask 对象具有以下属性。

Property Description 
Definition Gets the definition of the task. 
Enabled Gets or set a Boolean value that indicates if the registered task is enabled. 
LastRunTime Gets the time the registered task was last run. 
LastTaskResult Gets the results that were returned the last time the registered task was run. 
Name Gets the name of the registered task. 
NextRunTime Gets the time when the registered task is next scheduled to run. 
NumberOfMissedRuns Gets the number of times the registered task has missed a scheduled run. 
Path Gets the path to where the registered task is stored. 
State Gets the operational state of the registered task. 
XML Gets the XML-formatted registration information for the registered task. 

示例代码 [C++] 有关此脚本对象的更多信息和示例代码,请参阅时间触发器示例(脚本)和显示任务名称和状态(脚本)。

要求 客户端需要 Windows Vista。 类型库使用 Taskschd.tlb。

DLL 需要 Taskschd.dll。

另请参阅 任务计划程序对象 任务计划程序

将有关此主题的 cmets 发送给 Microsoft

构建日期:2006 年 10 月 2 日 语言 C++

显示全部 要求 客户端需要 Windows Vista。 类型库使用 Taskschd.tlb。

DLL 需要 Taskschd.dll。
也可以看看 任务计划程序对象 任务计划程序

将有关此主题的 cmets 发送给 Microsoft

构建日期:2006 年 10 月 2 日

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-20
    • 1970-01-01
    • 2018-12-20
    • 1970-01-01
    • 1970-01-01
    • 2019-05-02
    • 2016-06-23
    相关资源
    最近更新 更多