Python Forum
Odd behavior when starting Explorer.exe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Odd behavior when starting Explorer.exe
#1
I'm trying to successfully restart Explorer.exe (Windows 10) via Python 3.x. I'm using the subprocess module and it's run() function. Here's what I've observed:

* I always terminate explorer.exe via "taskkill /im explorer.exe /f". So throughout this post, that is how I do it.

* Restarting the process is trivial. I kill explorer, followed by calling "<path>\explorer.exe". Terminating explorer is fine and dandy, but restarting it through this method halts the calling script after the line to launch it.

* Terminating explorer.exe, followed by restarting it via calling "start explorer.exe" does not halt the script, but the behavior is not right. Doing it this way just launches a window/folder, the desktop is not restored. The script proceeds, however.

* Now on the Windows command line, terminating explorer and launching it via "start" works fine. The desktop is restored.

So, does anyone have experience restarting explorer, or any ideas how to make the run() call behave exactly as if I killed explorer via the command prompt? I need to restart explorer and have the script continue to process. There's something different about calling a command via run(), but I wonder if it can be fixed with an argument or combination of arguments.
Reply
#2
Further digging has led me to the following update as to point 3:

The reason starting explorer via "start explorer.exe" caused the desktop (taskbar, background, icons) to not be displayed is because I am using a 32 bit Python on 64 bit Windows. Something happens with starting the 32 bit explorer, not 64 bit. It can be corrected by the following sending the following argument to run(): 'c:\\windows\\sysnative\\cmd.exe /k start explorer.exe'. That starts the complete desktop by bypassing a native a Windows behavior.

However, the script still halts after the run() call. Something with launching a 64bit explorer via 32 bit Python? I don't know, but I'll keep digging.
Reply
#3
Well, I can launch Explorer in a separate thread and the main thread will continue uninterrupted. That'll do, but I'd still like to know why launching Explorer halts the script.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable Explorer in spyder driesdep 1 201 Apr-02-2024, 06:50 AM
Last Post: paul18fr
  Rename files in a folder named using windows explorer hitoxman 3 735 Aug-02-2023, 04:08 PM
Last Post: deanhystad
  File explorer DPaul 9 2,117 Aug-05-2022, 06:00 AM
Last Post: DPaul
  Renaming explorer files in order? stroudie2 2 2,873 Mar-03-2019, 12:41 AM
Last Post: stroudie2
  Looking through files in explorer in order? stroudie2 0 1,695 Mar-02-2019, 11:06 AM
Last Post: stroudie2
  Spyder hides middle array values in variable explorer window davidqvist 0 2,383 Aug-03-2018, 11:04 AM
Last Post: davidqvist
  Spyder IDE - make variable explorer to follow the color scheme of the Editor Antonio 0 5,438 May-05-2018, 10:20 PM
Last Post: Antonio

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020