Solved

Get the full path of a running process in Windows 2000/Xp

Posted on 2006-11-20
5
2,746 Views
Last Modified: 2008-01-09
How to get the full path of a specific running process called OnEarth.exe in Windows 2000/Xp. This path will be used to open a definition file and get a database name.
The purpose is as follows: This process can run from several directory locations. Each location contains the startup definition file from which the process gets the database name to connect with.
The perl script will connect to this database and run a sql program.
0
Comment
Question by:mordi
5 Comments
 
LVL 18

Accepted Solution

by:
Morcalavin earned 102 total points
ID: 17979548
use Win32::Process::Info;

$pi = Win32::Process::Info->new;
@info = $pi->GetProcInfo();
foreach(@info) {
      if($_->{Name} =~ /^OnEarth.exe$/) {
                #The below line will print the full path to the executable
            print "$_->{ExecutablePath}\n";
      }
}
0
 
LVL 3

Author Comment

by:mordi
ID: 17980667
I got following error:
Can't locate Win32/Process/Info.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/site/lib .) at C:\Mordi\Dba\perl\get_proc_path.
pl line 1.
BEGIN failed--compilation aborted at C:\Mordi\Dba\perl\get_proc_path.pl line 1.
0
 
LVL 18

Expert Comment

by:Morcalavin
ID: 17981003
You don't have it installed.  Bring up a console window, go to your c:\perl\bin direcotry and type:
ppm install Win32-Process-Info
0
 
LVL 8

Expert Comment

by:koppcha
ID: 17981011
You need to download that module from CPAN
0
 
LVL 39

Expert Comment

by:Adam314
ID: 17981030
You need to add that module.  If you are using activestate (my guess if on win2000), use PPM:

go to a command prompt
type "ppm {enter}"
at the ppm prompt, type "search win32"
you will get a list of modules, with a number to the left of each
look for "Win32-Process-Info" (you might have to hit space to get the next page)
notice the number next to it
type "i <number>", where number is from the previous step
type quit

try to run the above script again
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
delete query using perl dbi 3 108
Merge files & delete row based on criteria using Perl. 1 104
Regular Expression for URL 10 101
Perl File::Find alternative 1 78
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question