Rerun a program automatically in wsh if it dies or is shutdown 
Author Message
 Rerun a program automatically in wsh if it dies or is shutdown

Hi (im a newbie, please forgive),

I am trying to write a small vbs (wsh) script that respawns a program
if it is terminated...for example: if I run notepad.exe from the
script I want the script to go to sleep (or checks every 10 seconds or
so) until the program is killed or dies and then reexecutes the
program (notepad.exe).

how come it is so hard!!!

Thanks heaps,

Damien



Sat, 29 Jan 2005 21:10:01 GMT  
 Rerun a program automatically in wsh if it dies or is shutdown
Hi (im a newbie, please forgive),

I am trying to write a small vbs (wsh) script that respawns a program
if it is terminated...for example: if I run notepad.exe from the
script I want the script to go to sleep (or checks every 10 seconds or
so) until the program is killed or dies and then reexecutes the
program (notepad.exe).

how come it is so hard!!!

Thanks heaps,

Damien



Sat, 29 Jan 2005 21:10:01 GMT  
 Rerun a program automatically in wsh if it dies or is shutdown

Quote:

> Hi (im a newbie, please forgive),

> I am trying to write a small vbs (wsh) script that respawns a program
> if it is terminated...for example: if I run notepad.exe from the
> script I want the script to go to sleep (or checks every 10 seconds or
> so) until the program is killed or dies and then reexecutes the
> program (notepad.exe).

Hi

Here is a WMI\VBScript solution:

Set oShell = CreateObject("WScript.Shell")
Set oWmi = GetObject("winmgmts:")

' start notepad task
oShell.Run "notepad.exe"

' Waiting for solitaire to disappear
Do While True
  sWmiq = "select Name from Win32_Process where name='notepad.exe'"
  Set oQResult = oWmi.Execquery(sWmiq)

  If oQResult.Count = 0 Then
    ' start notepad task again
    oShell.Run "notepad.exe"
  End If
  WScript.Sleep 1000
Loop

--
torgeir



Sat, 29 Jan 2005 21:26:34 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Rerun a program automatically in wsh if it dies or is shutdown

2. VBScript before Shutdown automatically

3. How to run programs/.bat files on shutdown?

4. How SHUTDOWN a memory resident program ?

5. How to run programs/.bat files on shutdown?

6. Starting, hiding, and monetering a program till shutdown?

7. Shutdown program

8. Install a whole program automatically with VBS file?

9. using WSH to uninstall programs (add/remove programs)

10. Shutdown using WSH??

11. Unable to Shutdown Windows95 & reboot via WSH

12. Can I shutdown computer with WSH?

 

 
Powered by phpBB® Forum Software