Restarting explorer from a batch file only opens an explorer window
Posted
by
Ben Hooper
on Stack Overflow
See other posts from Stack Overflow
or by Ben Hooper
Published on 2012-06-08T18:19:41Z
Indexed on
2012/06/09
16:40 UTC
Read the original article
Hit count: 602
In one part of a batch file (kind of), I need to restart Explorer. I use the following method to accomplish this:
taskkill /f /im explorer.exe >nul
explorer.exe
:: I have also tried: %winDir%\explorer.exe
:: start %winDir%\explorer.exe
:: start /b %winDir%\explorer.exe
:: start /d %winDir%\explorer.exe (as suggested by panda-34)
::
:: I've even tried delaying the above commands with: ping localhost -n 11 >nul
Then this happens:
- explorer.exe is successfully terminated (denoted by the lack of taskbar and desktop)
- An explorer window opens, which I am left with indefinitely (see Image 1)
I can only then restart explorer by manually starting a new process from Task Manager (Win + R
doesn't respond), even though explorer.exe is actually already in the process list, strangely enough.. (see Image 2)
Now, I say "kind of" as I'm running the batch file from a self-executing SFX archive, created with WinRAR. When executed, the contents of the archive are extracted to %temp%
and a user-defined bootstrapper (in this case, my batch file) is run upon successful extraction.
The strangest thing about it, though, is that if you manually extract the contents of the archive and run the batch file then explorer restarts correctly. It only ever glitches when called from an SFX.
I'm experiencing this glitch on Windows 7 x64.
Link to an SFX archive demonstrating this, if anyone wants it: https://dl.dropbox.com/u/27573003/Social%20Distribution/restart-explorer.exe
Image 1:
Image 2:
© Stack Overflow or respective owner