Monday, March 17, 2014

Working with WMI (Windows Management Infrastructure)

Dim flag, AllProcess, AppToRun
AppToRun = “iexplore.exe”
Flag = Flase
Set AllProcess = GetObject(“winmgmts:”)
For Each Process In AllProcess.InstancesOf(“Win32_process”)
If (Instr ((Process.Name), AppToRun) = 1) Then
Print “Internet Explorer is running..”
Flag = Ture
Exit For
End If
Next
If Flag = Flase Then
Print “Internet Explorer  isnot running..”
SystemUtil.Run AppToRun
End If
You can do the same for any process/application. You just need to change the value of AppToRun variable. 

No comments:

Post a Comment