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!

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

Do While isProcessRunning(strComputer,strProcess) = True
      WshShell.Run "C:\Windows\Software\adobe.exe"
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.
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.
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)
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!

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
'When the process is NOT running, the above loop exits and the script continues:
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).
TECHSANTAAuthor Commented:
Not bad
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.