Solved

Script to check for running instance

Posted on 2011-02-23
5
564 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:musras
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:KCarney81
ID: 34965127
Although not VBS, you could start with batch;

sc \\computername query servicename >c:\textfile.txt
0
 

Author Comment

by:musras
ID: 34965175
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
 
LVL 3

Expert Comment

by:KCarney81
ID: 34965196
Ah ok, batch won't work for you then.  Figured I'd try
0
 

Accepted Solution

by:
musras earned 0 total points
ID: 34965437
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
 

Author Closing Comment

by:musras
ID: 34995557
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
how to add IIS SMTP to handle application/Scanner relays into office 365.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question