I have the following code that creates a process and then continually checks to make sure it's still running.
If it finds that it is closed, it creates it again and then loops forever.
My question is, can I have that loop run asynchronously so that I can run a bunch of other code in another loop.
Currently, I accomplish this by having two separate scripts and using Windows Task Scheduler to run them.
This set of code runs continually as fast as it can but the other code, I want it to run every 5 minutes.
I could accomplish this with a loop running every 5 minutes but I don't want to slow down this set of code.
I am just trying to combine the two scripts into one so I can lower the deployment overhead of this program.
Any suggestions?
Thanks!
If it finds that it is closed, it creates it again and then loops forever.
Code:
Set objWMIServiceWin32Process = GetObject("WinMgmts:\\.\root\cimv2:Win32_Process")
objWMIServiceWin32Process.Create strCmd1, null, null, intID1
objWMIServiceWin32Process.Create strCmd2, null, null, intID2
Set objWMIServiceRoot = GetObject("WinMgmts:\\.\root\cimv2")
Set colProcesses = objWMIServiceRoot.ExecNotificationQuery("Select * From __InstanceDeletionEvent Within 1 Where TargetInstance ISA 'Win32_Process'")
Do
Set objProcess = colProcesses.NextEvent
Select Case objProcess.TargetInstance.ProcessID
Case intID1
objWMIServiceWin32Process.Create strCmd1, null, null, intID1
Case intID2
objWMIServiceWin32Process.Create strCmd2, null, null, intID2
End Select
Loop
My question is, can I have that loop run asynchronously so that I can run a bunch of other code in another loop.
Currently, I accomplish this by having two separate scripts and using Windows Task Scheduler to run them.
This set of code runs continually as fast as it can but the other code, I want it to run every 5 minutes.
I could accomplish this with a loop running every 5 minutes but I don't want to slow down this set of code.
I am just trying to combine the two scripts into one so I can lower the deployment overhead of this program.
Any suggestions?
Thanks!