Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently developing a customized CafeSuite system for my Internet Cafe. And I'm using Java and JNI (Java Native Interface) to get through the Windows Registry. But I have this module I can't get or see if it is possible to work on Windows XP.

When I commanded on the Command-line, tasklist or tlist it would return me all of the running *.exe in the system. But with all of the parameters that could be added to the line, I can't see a parameter that would return the directory or path where an *.exe was executed.

Unfortunately, I am not using any Windows Server OS and am not to rely on any firewall of UAC or User Account Control feature of the OS.

With the given means, is it possible to pursue such concept?

share|improve this question
Do you just want to know where a process was started from, or do you need to determine this from within your app? Does it need to be command line? – Paul May 14 '12 at 5:02
All yes. I need to know the pathfile of each of process return by tasklist or tlist. Also, I need it to be in the command line for me to display the results within the program I am working on. – Cyril Horad May 14 '12 at 6:02
Perhaps you can try using WMI calls instead. Running "wmic process list" in the command prompt lists all running processes with the full path. With some batch-fu, you could technically extract the path of a running exe if it exists. – Mart May 14 '12 at 7:19
@Mart, could you provide details in regards of using wmic process list as an answer here. Thanks. – Cyril Horad May 14 '12 at 7:22
I could do that but that would take some time to dig around and research properly. If you try running that command and redirecting it to text file, you can see various properties. There is also some format specifiers and switches you could use to output that information into a CSV or XML file and to be parsed later. Add /? to any wmic command for help. – Mart May 14 '12 at 7:44
up vote 7 down vote accepted

In XP and above you can use the “System Information” tool, which shows the path.  You can run this from the menu at “Start” → “All Programs” → “Accessories” → “System Tools”, or from the command line as msinfo32  (or “Start” → “Run…” → msinfo32ENTER).

Click on “Software Environment” → “Running Tasks”, and the path is shown.

enter image description here

share|improve this answer

Using Windows Powershell, if you want to do find out the path for "firefox.exe, you could do:

(Get-WmiObject -class Win32_Process -Filter 'Name="firefox.exe"').path.SubString(0, (Get-WmiObject -class Win32_Process -Filter 'Name="firefox.exe"').path.LastIndexOf('\'))

This would return:

C:\Program Files (x86)\Mozilla Firefox

Replace "firefox.exe" with desired executable.

share|improve this answer
Am I going to prompt wmic before entering the command above? – Cyril Horad May 17 '12 at 7:52
Not needed. But you need to run those using Windows Powershell, not the command prompt. <code>Get-WmiObject</code> is a cmdlet in Powershell. You may run it with the <code>-?</code> switch for more help info. – Mart May 21 '12 at 8:28

I think this solved the problem. I have google it here about it and it worked using the commandline.

share|improve this answer
Your WMIC answer is OK but GlenG's answer is much better 'cos it's easy to remember and native. I suggest you change your accepted answer to his. – barlop Aug 28 '14 at 22:33
@barlop, your comment doesn't make sense -- wmic is native to Windows since XP. Additionally, it provides a text based output which is then able to be filtered easily with tools like findstr. – Daniel Mar 24 '15 at 17:56
@Daniel I agree my comment is rather strange. I do not know why I wrote that. Maybe I wasn't saying that WMIC wasn't native. I was saying Glen's answer is native and easy to remember. And in the strict boolean sense, Nano's isn't, because it's not as easy to remember, As in Glenn's meets both criteria.. nano's doesn't meet both criteria. WMIC being so large, it is a little subject in itself. but nothing wrong with it.. On a related note, He should've included the answer in his answer then it'd be a little bit more easy to remember but still not as easy to remember as Glen's.. – barlop Mar 24 '15 at 18:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .