Question:
Can I check, via scripts, if a program is being executed?
Solution:
Yes. By using winmgmts object and accessing the Win32_process instances, you can scan the name of all Windows processes. Then, all you will need is to test for the name of the desired process to know whether it is being executed.
For example:
set objService = getobject(“winmgmts:”)
for each Process in objService.InstancesOf(“Win32_process”)
if Process.Name = “calc.exe” then
a = 1
end if
Nextif a = 1 then
MsgBox “Calculator is being executed!”
else
Application.ExecuteExternalApp “calc.exe”, “”, “”, 1
end if
for each Process in objService.InstancesOf(“Win32_process”)
if Process.Name = “calc.exe” then
a = 1
end if
Nextif a = 1 then
MsgBox “Calculator is being executed!”
else
Application.ExecuteExternalApp “calc.exe”, “”, “”, 1
end if
NOTE: The sample application attached to this article was developed with E3 version 4.0 b225.