Работает в Windows 7, но не работает в Windows XP.
- Код: Выделить всё
Private Sub Form_Load()
Dim Service As TaskScheduler.TaskScheduler
Dim RootFolder As ITaskFolder
Dim Tasks As IRegisteredTaskCollection, Task As IRegisteredTask
Dim Action As IAction, ExecAction As IExecAction
Set Service = New TaskScheduler.TaskScheduler
Service.Connect
Set RootFolder = Service.GetFolder("\")
Set Tasks = RootFolder.GetTasks(1)
For Each Task In Tasks
Debug.Print Task.Name
For Each Action In Task.Definition.Actions
If Action.Type = TASK_ACTION_EXEC Then
Set ExecAction = Action
Debug.Print ExecAction.Path
End If
Next
Dim State As [_TASK_STATE]
Select Case State
Case TASK_STATE_UNKNOWN
taskState = "Unknown"
Case TASK_STATE_DISABLED
taskState = "Disabled"
Case TASK_STATE_QUEUED
taskState = "Queued"
Case TASK_STATE_READY
taskState = "Ready"
Case TASK_STATE_RUNNING
taskState = "Running"
End Select
Debug.Print "State: " & taskState
Next
End Sub
Получение списка задач, созданных с помощью команды AT.
Работает как в Windows XP, так и в Windows 7.
- Код: Выделить всё
Private Sub Form_Load()
Set WMI = GetObject("WinMgmts:")
Set objs = WMI.InstancesOf("Win32_ScheduledJob")
For Each obj In objs
Debug.Print obj.Command
Next
End Sub
Удаление всех задач, созданных с помощью команды AT.
- Код: Выделить всё
Private Sub Form_Load()
Set WMI = GetObject("WinMgmts:")
Set objs = WMI.InstancesOf("Win32_ScheduledJob")
For Each obj In objs
obj.Delete
Next
End Sub