Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way in Windows to check to see if a program is running (in this case a java application) and if it isn't running (because of a crash) re-run it?

share|improve this question
up vote 3 down vote accepted

Use PowerShell:

get-process name-pattern

will return details for each process matching name-pattern. If there is no match, then no applicable process is running:

if (@(Get-Process MyProcessName).Length -eq 0) {
  MyProcessName ...

(Using @(...) to ensure Get-Process returns an array in all cases.)

NB. if you need this to run frequently, then other options should also be considered (e.g. Performance Monitor alerts can launch an application, or even a custom service).

share|improve this answer
Also, fixing the reason that it crashes would be advisable – Matt Simmons Aug 4 '10 at 12:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.