Make VB script subroutine to check process

Hello to all VB Guru's

I'm trying to make a vb script (.vbs) subroutine that will:

Continually check if a process (.exe) is running
Once it's done running (finished), then launch another program (.exe).
 
Everything I've tried to far, doesn't work.

Really appreacate all your assistance!

-Mac
TECHSANTAAsked:
Who is Participating?
 
TECHSANTAConnect With a Mentor Author Commented:
This is what I have:

Do While isProcessRunning(strComputer,strProcess) = True
WScript.Sleep(2000)
Loop
      WshShell.Run "C:\Windows\Software\adobe.exe"
Wscript.exit
0
 
Ryan ChongCommented:
front my point of view, vb script is not naturally designed for the use to run constantly at background.

why not to design a service program that running at background for such process detection? you can write that service program in .NET/ JAVA or other favourite or programming language you're familiar with.
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
You haven't enumerated "everything" that you've tried so I have no idea why it's not working for you or what you're trying to use to check it.

Here's a function.
http://www.wisesoft.co.uk/scripts/vbscript_check_if_a_process_is_running.aspx
You could put a loop in place with a sleep option and check it once per second.  (I would NOT run it as just a continuous loop WITHOUT putting a reasonable delay)
1
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
TECHSANTAAuthor Commented:
Thank you for the your help.

It doesn't have to be a function or subroutine per say, just a way for the VB script to run in the background and continually check if a process is running. When that .exe stops, then run another .exe.

That function you sent looked okay, but I couldn't get it to work properly on a loop.

Any ideas?

Thank you for your assistance!

-Mac
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Can you post the code you tried to use in the loop?

A BASIC loop might look like this:

Do While IsProcessRunning("SomeProcess.exe") = True
   WScript.Sleep(1000)
Loop
'When the process is NOT running, the above loop exits and the script continues:
WScript.Shell("X:\Path\To\StartSomeOtherProcess.exe")
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
So what is not working?  Debug.

Add WScript.Echo comments and run from cscript to see what's going on (running by double click or WSCRIPT with an echo could be tedious).
0
 
TECHSANTAAuthor Commented:
Not bad
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.