Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

task scheduler is displaying an error "The specified query is invalid"

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.

like image 384
Mck Avatar asked Dec 16 '16 07:12

Mck


1 Answers

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"
like image 59
anilech Avatar answered Sep 22 '22 17:09

anilech