1

For a given task I need to determine what file it is trying to run with a batch code. Currently I use schtasks /query /TN ITCMD-CHAT-NOTIF | find "Ready" to determine if the task is active, but I see no way to determine what file it is executing. Is it possible?

2
  • If you add /v to the run string (schtasks /query /v /TN ITCMD-CHAT-NOTIF), one of the fields contains the schedule string, though it is limited to 50 characters. – AFH Sep 28 '18 at 17:56
  • Add a /v and remove the pipe with find and instead pipe it to a file, then please click edit above and add the result, so we can see more of what's going on. – K7AAY Sep 28 '18 at 17:56
0

To find the full path of the file being run, you can use the /XML switch and FIND "<Command>".

This gives you the XML file you would get if you exported the task, so you can't get both the Status and the Command fields using this command. Instead, you could create a batch file that will run both commands.

task_status.bat:

schtasks /query /TN %1 | find "Ready"
schtasks /query /TN %1 /XML | find "<Command>"

You can then run task_status.bat ITCMD-CHAT-NOTIF to get both fields of the task.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.