Script to check for running instance

I've spent 3,5 hours looking for a VB script that simply returns true if a process is present in Task Manager. I wish i had the time to learn how to do it, but i won't for another month or two.

Any VBS sharks that could help out?

Best
musras
musrasAsked:
Who is Participating?
 
musrasConnect With a Mentor Author Commented:
Ah found it...

'-----------------------------------------------------------
'  ProcTest.vbs (v1.0)
'-----------------------------------------------------------
' @proc = process to test for 
' Returns number of proccesses running or 0 if not 
'-----------------------------------------------------------

Function ProcTest(proc)
	ProcTest = 0

	set service = GetObject ("winmgmts:")

	for each Process in Service.InstancesOf ("Win32_Process")
		If Process.Name = proc then
			ProcTest = ProcTest + 1
		End If
	next
End Function

Open in new window

0
 
KCarney81Commented:
Although not VBS, you could start with batch;

sc \\computername query servicename >c:\textfile.txt
0
 
musrasAuthor Commented:
Thanks for the quick reply KC!

I'm (going to be) running the script from a system monitoring app that only works with VBS :/
0
 
KCarney81Commented:
Ah ok, batch won't work for you then.  Figured I'd try
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.