How to prevent multiple instances of a non-LC Windows app?

Mike Bonner bonnmike at gmail.com
Fri May 20 10:24:12 EDT 2011


In case it helps.. Adding documentation

' sets the environment
Set WshShell = WScript.CreateObject ("WScript.Shell")

'grabs the full processlist and puts it in a var
Set colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from
Win32_Process")


'loops through each looking for a match
For Each objProcess in colProcessList
If objProcess.name = "firefox.exe" then

'sets a flag if a match is found
vFound = True
End if

'next loop of course
Next

'if a match was found, activate the app
If vFound = True then
WshShell.AppActivate "firefox"
Else

' otherwise, run the app
WshShell.Run "firefox.exe"
End If



More information about the use-livecode mailing list