Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer


