Perhaps you can tell Explorer to show the path in the title bar, and then use the
WINDOWTITLE filter to kill it based on that?
- Open Explorer
- Press Alt
- Click on "Tools (menu item)"
- Click on "Folder options... (menu item)"
- Click on "View (page tab)" in "Folder Options"
- Click to select "Display the full path in the title bar (Classic theme only)" in "Folder Options"
- Click on "Apply" -> "OK"
The path won't show in Explorer's title bar with the 'non-classic' themes, but it is (now) there; it's just not visible.
taskkill /F /FI "WINDOWTITLE eq C:\PathToThing\RunningInExplorer\ToRestart*"
You may need to switch to a classic theme temporarily to determine what the path/title is for the Explorer instance you want to restart.
Not 100% fool-proof, but any Explorer windows that don't have that (partial) path in the title would be safe at least. :)
Since you want to grab the one with title "N/A", you'll probably have to use a batch file so that you can tokenize the results of a TASKLIST adn tehn use those token results to use TASKKIL to kill by PID.
I found an answer over to StackOverflow.com that addresses this:
From question Taskkill an untitled process? is this answer which includes this example batch file:
for /f "tokens=*" %%a in ('TASKLIST /V') do (
if '!t!'=='N/A' ECHO TASKKILL /PID !p! /T
You'll want to change the 'TASKLIST /V' command to be more specific to Explorer.exe and such, but it should give yo a good starting point.