1.

Solve : window closer?

Answer»

Hi all,
'i now its a bit a stupid question but the problem is that my knowledge about this stuff is very worse
so i hope you guy's can help me out with this one

Im trying to make a littel ms dos program that opens another program and after a while
(with a timer) closes the program and restarts it..

this is wath i have so far

@echo off
:loop
start Program.lnk
ping -n 10 localhost
taskkill /f /im Program

goto loop



if anyone could help me to make this work i would be fverry thankfull

greetz irradiateif i use this comand, then i open the program and after the s"set" time he opens the program again but the problem is that he doesnt shut down the old one..
so if their is a way to close it before reopen it my problem should be solved.. Welcome to the CH forums.

What is your purpose in doing this?

it's a program that has a limited online time,
so after that time it shoul be restartedyou better try :
CODE: [Select]ping -n 1 -w 1000 1.1.1.1 >nul-w 1000 make one sec pause. -w 2000 2 sec etc.
and :
Code: [Select]start /WAIT Program.lnkdunno about taskkill i havnt used itjust a few tweaks....


Code: [Select]@echo off
:loop
start notepad.exe
ping -n 10 localhost >nul
taskkill /f /im notepad.exe

goto loop

All I've changed is the program (to notepad), the ping line, I've added >nul to stop the output (but can be removed if you don't need it) and the taskkill line needs the full process name. including the .exe

hope it helps.
Either one of the suggested ping command lines will give you a delay. Use the >nul suggestion for either ping line.
The problem is that you do not have your program name entered correctly in the taskkill line.

Quote from: IRRADIATE on April 09, 2008, 04:10:02 PM

Code: [Select]taskkill /f /im Program

It must be EXACTLY what appears in the first column of the tasklist.
Run tasklist to see what the exact name is.
Likely it is program.exe. If so the following code will work.

Code: [Select]taskkill /f /im program.exe

Like blastman's line with notepad.exe:

Quote from: blastman link=topic=54842.msg344095#msg344095
[code
taskkill /f /im notepad.exe
[/code]
Thx alot for al your guy's help, it wroks now so i'm verry thankfull


Discussion

No Comment Found