Multiple Instances of Process
Moderators: JRL, Dorian (MJT support)
Multiple Instances of Process
How to detect multiple instances of, say, msched.exe?
Re: Multiple Instances of Process
Thanks for referring to the VBS code written by Marcus more than 10 years ago.
Thanks JBL.
Re: Multiple Instances of Process
It is a handy piece of code. I have 25 different scripts using it the last one was written only a month ago.armsys wrote:...the VBS code written by Marcus more than 10 years ago.
Re: Multiple Instances of Process
It's definitely useful.JRL wrote:It is a handy piece of code. I have 25 different scripts using it the last one was written only a month ago.
Recently, for some odd reason, when starting Windows, Macro Scheduler won't run, even though its link is listed in the StartUp folder--C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\Macro Scheduler.lnk.
A moment ago, I wrote the following script (located at %appdata%\Microsoft\Windows\Start Menu\Programs\Startup) to start Macro Scheduler as an automatic backup.
Thank you, Marcus & JRL.
Code: Select all
VBSTART
'returns the number of copies of ProcessName that are running
'will return 0 if ProcessName is not running
Function IsProcessRunning(ProcessName)
Set oWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = oWMIService.ExecQuery ("Select Name from Win32_Process where Name='" & ProcessName & "'")
IsProcessRunning = colProcessList.count
End Function
VBEND
// Find out the number (Num) of instances of Macro Scheduler
VBEval>IsProcessRunning("msched.exe"),Num
If>Num=1
Run>C:\Program Files (x86)\Macro Scheduler 14\msched.exe
Endif
Re: Multiple Instances of Process
How can we find out Marcus' other useful VBS snippets? 

Re: Multiple Instances of Process
Should be able to search forums to find more snippets.
Re: Multiple Instances of Process
Of course, I did. The keyword is VBSTART. You'll find plenty of useful VBS snippets. Thanks for your feedback.Meryl wrote:Should be able to search forums to find more snippets.