Kill a Task, have a 10 second delay, then restart task

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
natechie
Posts: 3
Joined: 09 Feb 2011 10:17

Kill a Task, have a 10 second delay, then restart task

#1 Post by natechie » 09 Feb 2011 11:03

Hello,

I have 50 computers that have Virtual PC 2007 (VPC) installed. I need to upgrade VPC to SP1. When I begin the upgrade, I get a little warning like this:

Image

I usually work around the error by starting Task Manager, killing explorer.exe, then click the retry button in the above image and the installation completes. Then, I have to open Task Manager again, then restart explorer.exe.

Obviously the kill/start process of explorer.exe will get quite tedious when upgrading VPC on these computers.

I'm working on a batch script that will kill explorer.exe. Then, I would like there to be a 10 second pause so I can finish the installation of VPC, then the script will automatically restart explorer.exe.

Unfortunately I'm not much of a scripter so I'm getting stuck at the time delay and restarting explorer.

For killing the task I'm thinking of using the simple taskkill /f /im "explorer.exe"

For restarting the task can I just use the simple "start explorer.exe" command?

I don't really need a scripting marvel, just something to the point that works. If someone can help me through a little script together, that would be great. Thanks so much for the help. :D

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Kill a Task, have a 10 second delay, then restart task

#2 Post by aGerman » 09 Feb 2011 12:07

Hmm, you have TASKKILL and START. What's missing, the 10s delay?

Code: Select all

ping -n 11 127.0.0.1 >nul


Regards
aGerman

natechie
Posts: 3
Joined: 09 Feb 2011 10:17

Re: Kill a Task, have a 10 second delay, then restart task

#3 Post by natechie » 09 Feb 2011 14:57

Thanks for the reply!

Yes, I'm missing the 10s delay.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Kill a Task, have a 10 second delay, then restart task

#4 Post by aGerman » 09 Feb 2011 15:14

Well then why don't you merge yours and mine to batch code :?

Code: Select all

@echo off
taskkill /f /im "explorer.exe"
ping -n 11 127.0.0.1 >nul
start explorer.exe

Otherwise you could call your upgrade instead of PING. Is it an exe file? Where is it saved?

Regards
aGerman

natechie
Posts: 3
Joined: 09 Feb 2011 10:17

Re: Kill a Task, have a 10 second delay, then restart task

#5 Post by natechie » 09 Feb 2011 21:31

Sorry, my second reply to this thread wasn't complete and I forgot to come back and update it. :oops:

Thanks for the

Code: Select all

ping -n 11 127.0.0.1 >nul


That was exactly what I needed. I combined the command with taskkill and start and it's running perfectly.

I'm simply saving it as a .bat.

Thanks so much for the help. I really appreciate it. :-)

Post Reply