1

I want something like this:-

taskkill 7z.exe after 50sec.
code 1
code 2
code 3 

7z.exe will be killed after 50 sec but the program should execute code 1 code 2 code 3 without waiting for the taskkill. May be 7z.exe would be killed when code 2 is being executed.

Deb
  • 209
  • 3
  • 5
  • 9
  • possible duplicate of [How do I make a batch file wait / sleep for some seconds?](http://superuser.com/questions/48231/how-do-i-make-a-batch-file-wait-sleep-for-some-seconds) – Synetech Jan 16 '14 at 16:19
  • Not quite a duplicate but definitely helpful to link that question. – benshepherd Jan 17 '14 at 08:45

2 Answers2

3

To kill 7z.exe after 50 seconds, you should use

start 7z.exe
timeout /t 50
taskkill /im 7z.exe

Put this in a batch file and use start to launch this process independently of the other (code1, code2, code3) stuff.

benshepherd
  • 1,641
  • 1
  • 9
  • 19
1

If CPU usage is important, may want to use ping with a loopback address and a timeout, like so:

@echo off
:: Pause for approx. 50 seconds
PING -n 51 127.0.0.1>NUL 2>&1

:: Force kill 7-zip
taskkill /f /im 7z.exe
JSanchez
  • 1,682
  • 13
  • 10