Good day.
This is the code in my function:
int num, ret, i
long pid
String ls_query, ls_name
Any process
ls_query = 'select * from Win32_Process where name = "appname.exe"'
locator = CREATE OleObject
ret = locator.ConnectToNewObject("WbemScripting.SWbemLocator");
service = locator.ConnectServer();
props = service.ExecQuery(ls_query);
num = props.count()
pid = props.processid
Messagebox("of_check_sp_running", "count = "+ string(num) + " and pid = "+ string(pid))
return num
num comes back with 0 if appname.exe is not running and > 0 when one or more appname.exes are running.
But I'm looking to get the processid, but it keeps crashing.
Googled and have not found anything that works.
My goal is to download a self extracting install app that will update the current running app.
So, if app123_servicepack.exe is running (because I just downloaded it from a website from appname.exe), terminate appname.exe using similar script above prior to clicking install on app123_servicepack.exe. I terminate using name in win32_processes, but it kills appname.exe and app123_servicepack.exe as well.
I'm thinking I can terminate appname.exe by the processid and it will hopefully not terminate app123_servicepack.exe as well.
Thanks for any help anyone can provide.
Great suggestion! That is what I also use in my frameworks. They work great!
@Dan here are some external functions that are useful for these sort of O/S inquiries ...
FUNCTION uLong GetCurrentProcess ( ) LIBRARY "KERNEL32.dll"
FUNCTION uLong GetCurrentProcessId ( ) LIBRARY "kernel32.dll"
FUNCTION uLong GetCurrentThread ( ) LIBRARY "KERNEL32.dll"
FUNCTION uLong GetCurrentThreadId ( ) LIBRARY "kernel32.dll"
Regards ... Chris