How to use wmic job get/list in CMD to get process name and location?

user939034 picture user939034 · Nov 18, 2011 · Viewed 37.2k times · Source

I need to get the exact location of a process name that a scheduled job is executing. I want to use WMIC JOB (if you have any other suggestions.. let me know) to get that, but I don't know HOW exactly. I've tried several variations but no luck so far.

How should I?

Answer

Lizz picture Lizz · Sep 9, 2014

The following will work, though you only need "CommandLine" or "ExecutablePath" - not both:

wmic process where "ProcessID=1111" get CommandLine, ExecutablePath

It will return something like the following, showing where the program for PID 1111 is running:

"C:\Program Files (x86)\Common Files\MyProgram\Agent\agent.exe"