>TRY > loCheckWMIService = Getobject("winmgmts:") >CATCH TO oExp WHEN oExp.Errorno = 1426 > * WMI is not installed >ENDTRY >>>I am trying to make sure that a second instance of the program is not running when a user starts. With one installation, we are getting the error Library Not Registered. I was assuming that I could count on it being available with Win ME and above. But I need to make a tighter check.
>>The code is >>IF "WINDOWS 5." $ UPPER(OS(1)) OR "WINDOWS 4.9" $ UPPER(OS(1)) >> IF HmProcessRunning("QPLAUNCH.EXE") > 1 >> MESSAGEBOX("QPLAUNCHER IS ALREADY RUNNING",0,"CANNOT START") >> DO SHUTITDOWN >> ENDIF >>ELSE >> IF IsWindEx2("QuotePro Launcher") >> DO SHUTITDOWN >> ENDIF >>ENDI >> >>**************************** >>FUNCTION HmProcessRunning >>**************************** >>LPARAMETERS PROCESS2CHECK >>PRIVATE nRetVal >>nRetVal = 0 >>lcComputer = '.' >>loWMIService = Getobject('winmgmts:'+ '{impersonationLevel=impersonate}!\\' + ; >lcComputer + '\root\cimv2') >>colProcessList = loWMIService.ExecQuery ('Select * from Win32_Process') >>For Each loProcess In colProcessList >> IF UPPER(loProcess.Name) = UPPER(process2check) >> nRetVal = nRetVal + 1 >> ENDIF >>ENDF >>RETURN nRetVal >>