Tuesday, September 28, 2010

Check if a windows process is running...

Hello Friends,
     During one of my project a requirement comes across to know whether a process is currently running on your machine or not. I looked across a number of sites, but none proved to be useful to me. But in the last I got some useful scripts which proved to be very efficient when applied through installscipt code.

The below script is in vb, which you could use through vbscript type custom action in your installshield project. In th variable PROCESS_NAME, you need to replace it by your process name, which you are looking for.

set service = GetObject ("winmgmts:")
for each Process in Service.InstancesOf ("Win32_Process")
      If Process.Name = "PROCESS_NAME" then
          wscript.echo "mmc running"
          wscript.quit             -- Here script will terminate
      End If
next

wscript.echo "mmc not running"         -- This code will execute if process is not running

No comments:

Post a Comment