Restart a Windows Application automatically if it crashes / shutsdown ?

raksrules

Elite
One of my laptop runs 24x7 and i have team viewer installed on it to enable remote access. So i can access the laptop even from my phone, other laptop as and when needed. Generally this setup works fine. But i have had one case wherein the team viewer crashed on the laptop and unfortunately i was not even in Pune at that time. I was in Mumbai and was going to reach Pune only after couple of days so that meant it could not really do anything. From my other laptop/phone the Pune laptop would always show offline for this reason, even when the laptop was on and connected to internet.
I did check on internet if there are ways to restart an application automatically whenever it crashed or closed and there are some options but not sure which is the most efficient.
Also testing them is bit difficult since crashes occur when they want and i cannot really reproduce a crash and a test case of closing app is possible but not the only thing i want. Restart from a crash is more important.
 
But with TightVNC installed on my laptop, is there a way to access the laptop remotely (over 3G or some other internet in another city) through iOS device ?
 
@rakrules: Let me give you a quick guide on how I setup my laptop.
I have my WiFi router that dials my connection. My router also has my no-ip dynamic DNS configured to register the dynamic public IP against my DNS entry. Now from the router I've forwarded a non standard port e.g. 6868 to 5900. 5900 is the standard port VNC listens for connections on.
After this I set a very strong password for VNC. And viola I'm done. I can access my laptop from any machine provided I have the VNC Viewer client or the VNC app on my mobile. In the VNC client I enter the DynDNS entry and the port e.g. mylaptop.no-ip.biz:6868 and I can access it. Its a little choppy depending on the connection you have, but one can manage.
 
@djmykey

That sounds a lot technical. I am not sure if i want to do this. I am completely comfortable with team viewer. I am also running an AutoIT script (in form of exe) on the laptop to remove the team viewer "sponsored session" message as i cannot even afford that message to be there. Because some things i run require the focus to be set on the browser always.
Also i have teamviewer app installed on my tablets and phone and computer so i know i am always able to easily connect.
Thanks for the information though. Alternatives are good.
 
@raksrules I understand buddy :) Its just that IMO TeamViewer seems to be a software to be used to remotely control a PC when there is a person in front of the PC coz it generate a ID and what not.
Also just becoz something is right it doesn't mean you need to do it :)
 
@djmykey

With Teamviewer, you do not need the person to be there. As of this moment, i can see my laptop at my home in Pune and my dad's laptop at home showing Online in my teamviewer app on iPhone. All these machines have been added to my team viewer account for unattended access and i do not need the other person to be near the laptop at all. All i do is select my online machine, connect it, do my tasks and disconnect. With no one actually there at my home in Pune as of now.
But yes in teamviewer for one time connectivity, you need other person to give you the password and all.
 
Some suggestions I can think of:
1. Once it crashes, if the Teamviewer service or process is no longer active (by active I mean visible on task manager), we can either use one of the Sysinternals tools or write a small C++ app to periodically check if the process is active and if not launch it.
2. Regardless of whether it crashed or not, periodically kill and relaunch it.
3. Periodically reboot the laptop.
 
@unni

Reboot can pose a risk for my tasks. If after restart, team viewer does not start (although I know it does) I won't be able to carry my tasks.
Last time when team viewer crashed and I was in another city and when I went back after 2 days, I saw some sort of this app has crashed, send error report and all.
Btw I am using windows xp and there is no way I am going to update or change OS.
Periodically restart the team viewer app can probably work. Not sure how I will do, may be through some batch script.
But easiest way seems to be download some application which restarts an application when it crashes.
I have a web link of a list of such apps and shall read their description properly and see.
 
You can use a simple vbscript like this one, this script checks every 60 seconds whether windows calculator is running if not launches the calculator process.
To use just copy the code into a file with extension .vbs and run it from a command prompt like "cscript <vbscriptfilename>" to avoid seeing the message box.
Replace calc.exe with your target process name , if it is a service instead of a simple exe which needs to be launched change the run command to "net start <servicename>"
Code:
set service = GetObject ("winmgmts:")
set Shell = CreateObject("WScript.Shell")
Do
running =0
for each Process in Service.InstancesOf ("Win32_Process")
    If Process.Name = "calc.exe" then
        wscript.echo "Calculator running"
        running = 1
    End If
next
If running= 0 then
  wscript.echo "Calculator not running launch it"
  Shell.Run "calc.exe", 0, False
End If
WScript.sleep 60000
wscript.echo "Checking status of calc again"
Loop Until 0
 
One more suggestion from my side.. I'm don't give up that easily :p :)
Install TeamViewer as a service.. then you get recovery options. Refer to the screenshot below. In an event that the service dies you can specify what you want to do. Refer to the screenshot below..

service.jpg
 
Weird - to the best of my knowledge, even when I manually kill the Teamviewer process, it respawns when I have enabled it to do remote logins. So something else might be stopping the process - check it out.

You could check RDP also as a failsafe. Just have a good password for logging in.
 
Can anyone suggest me how do i write a simple batch file or something which can every 2 or 3 hours kill and restart the team viewer app on my windows xp machine.
 
as i don't have XP, not sure if it's sleep or timeout here.

check if the following script performs open/close cycle for calculator, with 3 seconds wait in between. we can then make it more verbose or change it for team viewer app.

Code:
for /l %%x in (1,1,3) do (
timeout /T 3 /NOBREAK
taskkill /IM calc.exe
start calc.exe
)
 
as i don't have XP, not sure if it's sleep or timeout here.

check if the following script performs open/close cycle for calculator, with 3 seconds wait in between. we can then make it more verbose or change it for team viewer app.

Code:
for /l %%x in (1,1,3) do (
timeout /T 3 /NOBREAK
taskkill /IM calc.exe
start calc.exe
)


Thanks for this. I just copy pasted this in a txt file and renamed it to .bat and ran it.
It gave me some error about timeout not being a correct command but it opened 3 instances of calculator almost simultaneously (without any gaps in between).
 
Back
Top