Batch File to kill a process and re-run it....

Hi,

i want to create a batch file that can kill a process (program) and re-run it every half hour.

Detail problem :

I have my download rig connected to Lan for internet. It uses a client software to login. Often due to power failure in between somewhere, the net is down. As soon as the power is up, my client gets disconnected reason "Idle Time Out"

There is no way to change this setting. Only feasible solution seems to create a batch file that kills the program and then re-run it every half an hour. Since i dont know how to write it, can somebody help.... I would be very thankful....
 
im not good in batch programming..

i have another basic option...
set that program to run on startup.
& write a prograg to restart the PC every 30 minutes..

(add the bat file to start-->programs-->starup)
so if u want to cancel the program from startup..just move the file elsewhere..or write a batfile to rename it for you..:p

hope this cheap idea works for you...:)

to restart the system in 30 minutes
shutdown -r -f -t 1800
^where 1800 is no of seconds to wait before restarting..

To abort a shutdown/Restart
shutdown -a
 
Necessity is the mother of all inventions :)

Assuming that u want to work on windows I've written this post.

Batch program to do the trick? Hmmm.. I would suggest u go for a vb program. Simple and easy.

But if you want to stick with batch, let me give u a start,

Step 1:

edit the envi variable $path and add the folder from which UR PROGRAM has to be EXECUTED.

Example : winamp resides in C:\Program Files\Winamp

Add this path to $ variable.

Step 2: (This would be the start of ur program) lets name it trick.bat

Line 1:

Code:
taskkill /IM "program.exe"

Note: needn't use quotes

this would return with the PID and SUCCESS if program is already running.

Else ERROR.

Line 2:

Code:
program.exe

This simple program would just kill the process and start it up again.

I've got an exam tom and i don't have time to spend tonight, will get back soon.

PS: Again I am telling ya, Use VB, u can write simple applications and add it at startup.

Its very simple and effective :)
 
Dude!

Forget the Batch program i was talking about.

Getting an idea from the start up trick super_saiyan was referring to. I wondered if we could make that DOWNLOAD application a windows service, so that windows automatically takes care of starting it and killing if there was some problem. After some googling i found this tool

I am sure this is userfriendly.

after installation

in the tool,

create new service

type the serive name, select the application to run

then goto settings tab.

logon tab,

Check Interact with desktop

service lifecycle,

start type select AUTOMATIC

upon pgm exit : Restart the pgm

Install.

Now open services from admin tools (control panel)

You should be able to see the service u just created.

Select the service -> properties

goto recovery tab.

Select Restart the service option under all failure conditions.

Now one more important thing to note

Give the time to restart the service(in ur case 30 minutes)

You are done.

Enjoy!

I Wrote these steps in haste... and i gotta cram now..

Just play with the options to set it right. ( Even i just checked this app for the first time)

got an EXAMMMMMMMMMMMMMMMMmm.... tom... :(

:D Enjoy man
 
sorry for the late reply.... was buzi

i tried to find a batch to killa program using the image name as mention above....after that i used a scheduler to run the batch file once every 30 mins and then the program on the 31st minute.

Restrating PC cannot be done coz, if i can kill the program and restart it, my download hardly gets affected, hence looking for the same.

_____________
Tried the stuff.... the idea is really good but i think my client uses some parameters hence giving error that it is curropt and reinstall, but when u manually click it, its starting rpoperly....

Also the programs App-as-Service is a 14 day trial, so does that means creating service using it will run only for 14 days....

I have seen somewhere over the net that u can make any exe run as service....will search on it... but how to find the prameters....

or can u please write a small code that restarts the service every half hour, although keep the program directory and time to restart as changeable....
Would be thankful to you...

But all that after ur exams... so get back to study... BEST OF LUCK...
 

Attachments

  • CyberoamClientInstallation.zip
    339.3 KB · Views: 323
I think the services would work after 14 days. The program to create the service alone would expire i believe.

Btw, what are the parameters u are talking about? and what kinda program do you need? Be specific on the sw you are using too.

I'll see if i can help you man!

PS: Exams are over :D. thanks anyways!
 
U download client gives time out error or is it ur internet client software?

I had a problem with one of my servers. The ISP used to disconnect me if the connection was not used after sometime. So i wrote some script to take care of that. So if ur problem is similar let me know.
 
Josh said:
U download client gives time out error or is it ur internet client software?

I had a problem with one of my servers. The ISP used to disconnect me if the connection was not used after sometime. So i wrote some script to take care of that. So if ur problem is similar let me know.
the problem is with my internet client software, it gives me the reason " YOU HAVE BEEN DISCONECTED BY ADMINISTRATOR : REASON IDLE TIME OUT"... all i need is a program that kills the process and starts the program every 30 minutes....

also jayken, given the software as zip for u to try out..... in my previous post....its very common software used many places in mumbai for cable internet connection using lan.....
 
neo,

I tried adding your client to the scheduled tasks.

But it fails saying no username was provided.

Try making use of that buddy.

Try to add that EXE into scheduled tasks, there u can specify in the settings.

Then on u can take it up.

if u have any more hassles let me know. from my place its not getting connected to that server man.
 
Back
Top