It is not TaskKill's fault. While you have opened two File Explorer windows, this does not necessarily mean that you have opened two separate processes for each.
One of the settings that can impact your situation can be found under:
Folder Options → View tab → Advanced settings → "Launch folder windows in a separate process"
This setting has the following effects:
- If this checkbox is not checked, most of the times, File Explorer windows are opened in the same
explorer.exe process that hosts task bar and Start menu. This process's window title is fixed. If you kill this process, you entire Windows shell disappears.
- If this checkbox is checked, the process that hosts task bar and Start menu is always separate from the process hosting your File Explorer windows. But still, this does not mean that you get one separate
explorer.exe process for each File Explorer window. I tested this in Windows Server 2008 R2 and Windows 10 1709. I always get exactly one
explorer.exe process for all my File Explorer windows and one other
explorer.exe for my taskbar and Start menu. The
WINDOWTITLE of that process is always the title of the File Explorer window that was open last.
One reason that
subprocess.Popen() opens a separate File Explorer process could be that you are running a 32-bit Python on a 64-bit computer, in which case,
subprocess.Popen() just opens a 32-bit
explorer.exe. (This does not happen in all versions of Windows, but again, you didn't specify any.) Another reason is out-of-process DCOM invocation that always trips me up.
But the gist of it is: