Page 1 of 1 1
Topic Options
#203317 - 2011-10-22 05:27 PM Check for running process
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Just a quick question for you all. I'm using kix2exe to package kixtart/kixforms apps and running them from client desktops. But I'm having a hard time figuring out a way to tell if the app is already running or not when it is launched. I was using the below simple UDF, but of course, it does not help if somebody renames the executable. Anybody know how to retrieve the 'original file name' from the version info for example?

 Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;  CHECKS FOR A RUNNING PROGRAM.                ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Function CheckForProcess($exe)
   Dim $processes,$process
   $processes=GetObject("winmgmts:{impersonationLevel=impersonate}!root\cimv2").ExecQuery("select * from Win32_Process")
   For Each $process in $processes
      If $process.Name = $exe
         $CheckForProcess=$CheckForProcess+1
      EndIf
   Next
EndFunction

Top
#203318 - 2011-10-22 05:35 PM Re: Check for running process [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Never mind, I was over-complicating it. The built-in GetFileVersion in KiX returns the OriginalFilename \:\)
Top
#203319 - 2011-10-22 05:39 PM Re: Check for running process [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Am now using the following function which works even if the exe has been renamed (as long as you know the original filename).

In case anyone else finds it useful...

 Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;  CHECKS FOR A RUNNING PROGRAM.                ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Function CheckForProcess($exe)
   Dim $processes,$process
   $processes=GetObject("winmgmts:{impersonationLevel=impersonate}!root\cimv2").ExecQuery("select * from Win32_Process")
   For Each $process in $processes
      If GetFileVersion($process.ExecutablePath,"OriginalFilename") = $exe
         $CheckForProcess=$CheckForProcess+1
      EndIf
   Next
EndFunction

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 235 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.057 seconds in which 0.03 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org