KB-56005: Checking whether the program is being executed.

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

NOTE: The sample application attached to this article was developed with E3 version 4.0 b225.

Attachments:

Sample

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *