ValueError: can't format dates this early
ValueError: can't format dates this early
我正在尝试使用 ITASKDEFINITION 获取计划任务的下一个 运行 时间,但我在获取下一个 运行 时间时遇到了问题我收到错误
Traceback (most recent call last):
File "WSTC.py", line 34, in <module>
print('NextRun : %s\n' % task.NextRunTime)
ValueError: can't format dates this early
示例代码如下:
import win32com.client
TASK_ENUM_HIDDEN = 0
TASK_STATE = {0: 'Unknown',
1: 'Disabled',
2: 'Queued',
3: 'Ready',
4: 'Running'}
scheduler = win32com.client.Dispatch('Schedule.Service')
scheduler.Connect()
folders = [scheduler.GetFolder('\')]
n = 0
while folders:
folder = folders.pop(0)
folders += list(folder.GetFolders(0))
tasks = list(folder.GetTasks(TASK_ENUM_HIDDEN))
for task in tasks:
settings = task.Definition.Settings
if TASK_STATE[task.State] == 'Running':
print('Path : %s' % task.Path)
print('State : %s' % TASK_STATE[task.State])
print('NextRun : %s\n' % task.NextRunTime)
n += 1
print ('Listed %d tasks.' % n)
非常感谢对此的任何帮助或帮助。谢谢!
我正在尝试使用 ITASKDEFINITION 获取计划任务的下一个 运行 时间,但我在获取下一个 运行 时间时遇到了问题我收到错误
Traceback (most recent call last):
File "WSTC.py", line 34, in <module>
print('NextRun : %s\n' % task.NextRunTime)
ValueError: can't format dates this early
示例代码如下:
import win32com.client
TASK_ENUM_HIDDEN = 0
TASK_STATE = {0: 'Unknown',
1: 'Disabled',
2: 'Queued',
3: 'Ready',
4: 'Running'}
scheduler = win32com.client.Dispatch('Schedule.Service')
scheduler.Connect()
folders = [scheduler.GetFolder('\')]
n = 0
while folders:
folder = folders.pop(0)
folders += list(folder.GetFolders(0))
tasks = list(folder.GetTasks(TASK_ENUM_HIDDEN))
for task in tasks:
settings = task.Definition.Settings
if TASK_STATE[task.State] == 'Running':
print('Path : %s' % task.Path)
print('State : %s' % TASK_STATE[task.State])
print('NextRun : %s\n' % task.NextRunTime)
n += 1
print ('Listed %d tasks.' % n)
非常感谢对此的任何帮助或帮助。谢谢!