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?
1 Answer
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.
/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.edit
above and add the result, so we can see more of what's going on.