how to relaunch a program if user close the program, i already have the script to start a program which is folowwing @ECHO.
@ECHO Loading Premise Law Library...
@ECHO OFF
ping 192.168.1.2 -n 20 -w 1000 > nul
rem START "" "\\tst-ll\WestGroup\program files\West Group\Premise\winprs\WinPrs.exe"
start "" "\\tst-ll\WestGroup\program files\West Group\Premise\winprs\winprs.exe"
EXITNow i want to add a code where if user closes this program , it wshould automatically run that program again.
does winprs leave an exit code? if not you could make your own (have a batch file set an env var called status as running, call winprs.exe, then when the user closes the batch file, then generate the status envvar as closed.) just loop the batch and check for %status%. gl
Can you write the script for this, I am not good in scripting, also winprs.exe is an application, where user can close this application. We are running a batch file from Shell, so all the other windows services and program dont run but this batch file, once user close this application, they see a blue screen. I hope u understand what i am saying...
just check the process list with batch and see if your program is running if not start it then put a 1 second or more wait in between times it checks.
then make it also loop
ex:
@echo off
:check
tasklist /FI "IMAGENAME eq myapp.exe" 2>NUL | find /I /N "myapp.exe">NUL
if "%ERRORLEVEL%"=="0" goto running:running
:: This will have it wait about 1 second change "1000" to make it wait longer
PING 1.1.1.1 -n 1 -w 1000 >NUL
echo.
echo Checking if program is running..
echo.
cls
goto check:not_running
cls
echo.
echo Starting program
echo.
start "your file"
goto check
I did not test this but im pretty sure it will work
Note: If the PC gets a BSOD when the application closes, there's not much a script can do. @ECHO. @ECHO Loading Premise Law Library... @ECHO OFF ping 192.168.1.2 -n 20 -w 1000 > nul :loop start /wait "" "\\tst-ll\WestGroup\program files\West Group\Premise\winprs\winprs.exe" goto loop
I think I understand what Rajeshnayyar is referring to by bluescreen (not a BSOD, but rather the absence of explorer).
I would place the application path in your registry's shell line: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell
Then create a scheduled task that runs every 1 minute minimized to check that the program is running:
@echo off
tasklist | findstr /i WinPrs.exe
if %errorlevel% neq 0 goto restart
goto end
:restart
start "" "\\tst-ll\WestGroup\program files\West Group\Premise\winprs\winprs.exe"
:end
exit
you are absolutely right...., i am going to try your script and let you know, also rather that putting the the application path in the Shell, I am putting the batch file path in the shell as i need to run one more than one application in the shell mode.
Thanks for your help.
| « Visual Basic - Noughts & ... | [Solved] What Are the Special Char... » |