This shows you the differences between two versions of the page.
Previous revision | |||
— | fuss:vbscript [2022/04/19 08:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Process Restarter ====== | ||
+ | |||
+ | The following script can be used to start a process and, upon termination, | ||
+ | |||
+ | <file vbscript restartShell.vbs> | ||
+ | ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | ||
+ | '' | ||
+ | ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | ||
+ | |||
+ | If WScript.Arguments.Count = 0 then | ||
+ | WScript.Echo " | ||
+ | WScript.Quit 1 | ||
+ | End If | ||
+ | |||
+ | Set fileSystemObject = CreateObject(" | ||
+ | If Not fileSystemObject.FileExists(WScript.Arguments.Item(0)) Then | ||
+ | WScript.Echo "File not found" | ||
+ | WScript.Quit 1 | ||
+ | End If | ||
+ | |||
+ | args = """" | ||
+ | i = 1 | ||
+ | Do While i < WScript.Arguments.Count | ||
+ | args = args & " " & WScript.Arguments.Item(i) | ||
+ | i = i + 1 | ||
+ | Loop | ||
+ | |||
+ | Set WshShell = CreateObject(" | ||
+ | Do While True | ||
+ | WshShell.Run "" | ||
+ | If MsgBox(" | ||
+ | WScript.Quit 0 | ||
+ | End If | ||
+ | Loop | ||
+ | |||
+ | </ | ||
+ | |||
+ | Given that the script would be placed at '' | ||
+ | <code dos> | ||
+ | C: | ||
+ | </ | ||
+ | |||
+ | such that when '' | ||
+ | |||
+ | The script also takes care to pass all command line arguments on thereby allowing commands to be executed with parameters. | ||