8

I am running Windows 10.

I'm trying to run a backup job (C:\WINDOWS\system32\robocopy.exe) using Task Scheduler. But I was getting issues. To figure out what was going on, I turned on the history log. Unfortunately since doing that, every time I click the History tab I get the following error:


Dialog Title: "Query Error"

Dialog Message: "One or more logs in the query have errors."

The table in the dialog: "Microsoft-Windows-Task-Scheduler/Operational | The specified query is invalid"

"The events displayed are partial results."

Nothing appears in the History pane, so I cannot debug either problem. Does anyone know what is going on?


I am having the exact same error as in

https://www.experts-exchange.com/questions/27676176/Query-Error-In-Microsoft-Task-Scheduler.html

The answer is at

http://www.minasi.com/forum/topic.asp?TOPIC_ID=27906


The answer site (www.minasi.com) is apparently moved and did not retain the answer so cannot try the fix that solved his problem.

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Mck
  • 129
  • 1
  • 10

1 Answers1

12

Please check if you have single quotes (apostrophes) in the task name. It is known that the apostrophe in the task name breaks task history. To remove them you can try following batch file (it exports task to the xml file, imports it with the new name and removes the old task):

@set "tn=my PC's task"
@if not "%tn%"=="%tn:'=%" echo renaming "%tn%" ==^> "%tn:'=%" && ^
schtasks.exe /query /tn "%tn%" /xml>"%temp%\%tn:\=_%.xml" && ^
schtasks.exe /create /tn "%tn:'=%" /xml "%temp%\%tn:\=_%.xml" && ^
schtasks.exe /delete /tn "%tn%" /f && del /q /f "%temp%\%tn:\=_%.xml"
anilech
  • 1,089
  • 8
  • 9
  • 2
    I ran into this issue as well. I created a scheduled task with an apostrophe and renaming it without the apostrophe saved the day. Huge help. Thanks, I was able to rename the task by right clicking on the task in the scheduled task viewer, export, and then Import Task (on the right hand Actions panel) and I was able to rename and save. – Cody Lohse Oct 18 '17 at 01:59
  • 2
    I had the same problem - but the apostrophe was in the folder name. I couldn't find a way to rename the folder, so I exported my tasks to XML files and then imported them into the new folder. Now the history works. :-) Thanks @anilech! – Robert Aug 01 '19 at 14:28
  • Thank you. I was in the same boat as Robert. Apostrophe in the folder name. I will note that the task scheduler ALLOWED me to create a folder with an apostrophe in it. It's a good thing the folks working at Microsoft have no shame or a bug like this might have been fixed YEARS ago. (of course... if they actually cared, we'd also be able to rename the folders and drag and drop tasks by now too) – Frog Pr1nce Jul 12 '23 at 16:08