2

I want something like this:-

taskkill 7z.exe after 50sec.
Execute few lines of codes without waiting for 7z.exe to be killed. 

It will automatically be killed after 50sec, wherever the execution is going on.

Deb
  • 5,163
  • 7
  • 30
  • 45

2 Answers2

2

Is this what you mean ? Waiting 50 seconds before killing 7z.exe

Timeout 50 
taskill /f /im 7z.exe

or you want to wait after killing then do some commands.

taskill /f /im 7z.exe
Timeout 50 
REM do commands here.

EDIT: New version for OP.

start "7z killer" cmd "/c Timeout 50 && taskkill.exe /f /im 7z.exe"
echo "do something immediately"
Knuckle-Dragger
  • 6,644
  • 4
  • 26
  • 41
  • Wait 50 sec before killing 7z.exe. But do not pause the program. Keep executing other lines. Is the first one solution of that? – Deb Jan 16 '14 at 15:51
  • Thanks. It worked. Please tell me a way to turn off the counting window. – Deb Jan 16 '14 at 16:55
  • probably could do it with the old invisible.vbs trick http://stackoverflow.com/questions/19750808/need-help-running-a-batch-invisibly-from-another-batch or http://superuser.com/questions/62525/run-a-completly-hidden-batch-file – Knuckle-Dragger Jan 16 '14 at 17:38
0

OK, here is a way to turn off the counting window, in addition to all the other stuff.

echo CreateObject("Wscript.Shell").Run """" ^& WScript.Arguments(0) ^& """", 0, False>Invisible.vbs
echo Timeout 50 ^&^& taskkill.exe /f /im 7z.exe>killer.bat
wscript Invisible.vbs killer.bat
echo "do something"

This creates two files in the same directory as itself, invisible.vbs and killer.bat then executes killer.bat invisibly with the 3rd line.

Knuckle-Dragger
  • 6,644
  • 4
  • 26
  • 41
  • The `wscript` line replaces the `start` from the previous example. That's how I make it invisible the counting window. – Knuckle-Dragger Jan 17 '14 at 08:52
  • Ya , its invisible now. But the taskkiller is not running.i.e, I think the commands that were supposed to be executed in the new window(in your previous example) is not running now. – Deb Jan 17 '14 at 12:52