Restarting Explorer
Hello,
Every time I try to run a script that restarts explorer it successfully shuts down Explorer but afterwards does not come back.
I've tried,
Taskkill /IM explorer.exe /F&&explorer.exe
and
Taskkill /IM explorer.exe /F
explorer.exe
and
Taskkill /IM explorer.exe /F
explorer
and
Taskkill /IM explorer.exe /F
start explorer.exe
and
Taskkill /IM explorer.exe /F
start c:\windows\system32\explorer.exe
Nothing seems to kick off explorer except going to the system manually opening run from task manager and typing "explorer"
What am I doing wrong?
Comments
It could be having a problem because it's trying to start explorer too soon after killing it. Try adding a pause in between:
taskkill /im explorer.exe /f
timeout /t 3 /nobreak
start explorer.exe
This is the output I received,
SUCCESS: The process "explorer.exe" with PID 4320 has been terminated.
ERROR: Input redirection is not supported, exiting the process immediately.
From your error it looks like the startup process is trying to startup explorer while it's still in the process of shutting down.
The timeout suggested by Luke above should work for you.
When I tested my suggestion I got the same input redirection error as Anthony. When I took out the timeout portion that error went away. I'm not sure why it's having an issue with that, maybe try taking out the /nobreak switch?
Got the same error when taking out /nobreak
SUCCESS: The process "explorer.exe" with PID 7720 has been terminated.
SUCCESS: The process "explorer.exe" with PID 7612 has been terminated.
ERROR: Input redirection is not supported, exiting the process immediately.
What? No powershell?
This kills explorer on my machine, and it instantly recovers when it quits.
That's weird, I'll see if I have a chance to test some stuff later this afternoon.
Oh wait, just realized you are talking about Explorer and not Internet Explorer. DOH!
Powershell for the win! :-)
Yes, is PowerShell an option? You should just be able to do this command in PowerShell, which I confirmed as working on Windows 10 1709 x64 but might not work on W7:
stop-process -ProcessName explorer
It also automatically starts the process again afterward.