I'm trying to create a bat or shell script that will let me check if my plink connection dies or becomes unresponsive and then kill the service and start it up again. It that possible?
The problem my and my buddy encountered is that we can't seem to check if the process has died on us or not and right now our solution is to use a timeout. this is a bit of a waste of time as the connection could die and stay dead for whoever knows how long or it could get killed even if it's perfectly fine.
:LOOP
START CMD /C "title connection && plink sap" > data
timeout /t 30
START CMD /C "taskkill /fi "Status eq RUNNING" /fi "WindowTitle eq connection*" /im "cmd.exe && exit"
timeout /t 5
GOTO LOOP