Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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. –  NanoGM 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. –  NanoGM May 14 '12 at 7:22
    
I could do that but that would take some time to dig around microsoft.com 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

3 Answers 3

up vote 3 down vote accepted

In XP you can run the All programs > Accessories > System tools > System Information tool which shows the path.

Click on Software Environment > Running Tasks and the path is shown.

http://www.raymond.cc/blog/determine-program-path-from-task-manager-for-each-program-in-windows-xp-windows-server-2003/

added by barlop-

start..run..msinfo32<ENTER>

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? –  NanoGM 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 11 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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