Need help with a very basic batch file code

Stg-Flame

Diamond Member
Mar 10, 2007
3,578
519
126
Long story short, I need explorer.exe to close before opening a program, stay closed while it's open, then restart when I close the program.

The first two steps were simple for me (my programming knowledge ranges from nonexistent to elementary), but the last step has me stumped.

What I have right now is:

Taskkill /f /IM explorer.exe
Start "" "C:\program\program.exe"

I'm not sure what to add next that doesn't involve a timer. All my attempts thus far either won't restart explorer or it starts it immediately after the program starts. Any help is appreciated. I know I can just start explorer manually from the task manager but that defeats the whole purpose of using a batch file.

Edit: The sad emoticon made me laugh since it fits the mood of the thread.
 

TheELF

Diamond Member
Dec 22, 2012
4,026
753
126
Don't use start to start the program since that is the (kinda) multitasking command to do this,use the path to the program only and it will start up and the batch will continue as soon as the program stops.
 

PhIlLy ChEeSe

Senior member
Apr 1, 2013
962
0
0
Long story short, I need explorer.exe to close before opening a program, stay closed while it's open, then restart when I close the program.

The first two steps were simple for me (my programming knowledge ranges from nonexistent to elementary), but the last step has me stumped.

What I have right now is:

Taskkill /f /IM explorer.exe
Start "" "C:\program\program.exe"

I'm not sure what to add next that doesn't involve a timer. All my attempts thus far either won't restart explorer or it starts it immediately after the program starts. Any help is appreciated. I know I can just start explorer manually from the task manager but that defeats the whole purpose of using a batch file.

Edit: The sad emoticon made me laugh since it fits the mood of the thread.

OK, sounds like your a software guru lol sorry! I do this same action(for over clocking) I shut down explorer.exe under Windows task manager(control/alt/delete) under the processes tab. Then I add priority to the software im gonna run IE 3Dmark blah blah, then after 3Dmark blah has finished. I hit the "FILE" tab in task manager(then "NEW TASK RUN"), as I have done/do this so much the first file offered is "explorer.exe". Sometime's in my haste, I flick it and have to manually input the words. But never had an issue with doing this, I assume maybe you need to do this while windows is starting? Or prior to?
Anywho hope it helps ya as thats why we r here..
 

Zalez

Senior member
Aug 9, 2001
219
0
71
TheElf is right. Just call the path of the program that you want to run which will be blocking. Then use "Start" to call explorer.
taskkill /f /IM explorer.exe
C: \"Program Files"\MyApp\MyExec.exe
start C: \Windows\explorer.exe
Note: I placed a space in the path to avoid the emoticon being inserted.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,340
4,018
75
Long story short, I need explorer.exe to close before opening a program
I'd like to get a little more of the story. Why do you need to kill Windows Explorer?
 

Stg-Flame

Diamond Member
Mar 10, 2007
3,578
519
126
TheElf is right. Just call the path of the program that you want to run which will be blocking. Then use "Start" to call explorer.

Note: I placed a space in the path to avoid the emoticon being inserted.

That still starts explorer the moment the program is started. I need explorer to be stopped for the duration that the program is running. I'm thinking of a simple if/then statement of "if program is running then taskkill explorer.exe" "if program closes, then start explorer.exe".

I'm not sure if that's even possible with just a batch file but I'd like to think someone knows the parameters for starting a program once another has stopped.

As for why, during a recent flood I've discovered a lot of old programs that me and a friend used to play with and I'm trying to get them to run on windows 7 but it seems for whatever unknown reason, having explorer running causes massive glitches and graphical errors. Some of these I've had to dig out my old 5.5" floppy drive to get the files. I'm trying to keep this brief since typing on a phone is a pain in the ass.
 

TheELF

Diamond Member
Dec 22, 2012
4,026
753
126
Ok you have to use the wait command,no need for if/then

taskkill /f /IM explorer.exe
d: \games\oldschoolgame.exe
wait
start C: \Windows\explorer.exe
 

Tweak155

Lifer
Sep 23, 2003
11,448
262
126
When I had to do this to run Diablo, I put "pause" on the line before the start call. This way the CMD window stayed open until I closed the game, it then made the CMD window active and I just hit any key on the keyboard and BOOM, Windows is back!
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |