1

I want to start a new instance of explorer.exe every time I run start \\path even if the same path is already launched in a window. Currently it works like this:

start C:\Users

It launches a window with that path

start C:\Users

It focuses on the previously opened window

EDIT

The word instance is unfortunate I guess. I meant that I want to open another window of File Explorer, not another instance of it.

phuclv
  • 26,555
  • 15
  • 113
  • 235
K0SS4
  • 11
  • 2
  • Only one instance of File Explorer can be running at a time – Ramhound Apr 17 '22 at 23:38
  • I don't think so. If I run start with a different path then it opens up a new instance – K0SS4 Apr 17 '22 at 23:39
  • Windows 11 I can only get one instance running as @Ramhound noted. Windows 10, I can open a new File Explorer Window and have two windows open. In Windows 10 if I try to open File Explorer again, it goes to one on the open Windows (most recent). – John Apr 18 '22 at 00:10
  • Also it occurs to me that two windows of one instance is not two instances. Are you looking for just another window? Look in File Explorer Options, General Tab, – John Apr 18 '22 at 01:24
  • 1
    You can have many windows open, but there will only be a single File Explorer process. – Ramhound Apr 18 '22 at 01:34
  • You need to explain yourself. Explore.exe is a critical Windows process and there should usually only be one instance of this. File Explorer is a sub process and there can be multiple of these. You need to be precise in what you're describing, because despite what the words of your question say it seems you're talking about something other than what you wrote. – music2myear Apr 18 '22 at 03:54
  • Okay sorry. I corrected the post – K0SS4 Apr 18 '22 at 07:17
  • @Ramhound that's not true. The ["launch folder windows in a separate process"](https://i.stack.imgur.com/5ujP0.png) option in Explorer has been there for decades. [Launch each Windows Explorer window in a separate process](https://superuser.com/q/710231/241386), [How do I make Windows launch a new instance of explorer.exe when I open My Computer?](https://superuser.com/q/12591/241386) – phuclv May 13 '22 at 15:41
  • @John you can run multiple explorer processes without problem. It's just disabled by default in the past to save memory [How can two instances of explorer.exe be running at the same time?](https://superuser.com/q/323587/241386) – phuclv May 13 '22 at 15:42

1 Answers1

0

Note: This is a solution for Windows 11 and has been confirmed to work. For Windows 10 you'll need a different solution at the end of this answer

You can get the Shell.Application Scriptable Shell Objects to manipulate the Windows shell easily. In PowerShell each time you run the below command a new Explorer will open

(New-Object -ComObject Shell.Application).Explore("C:\Users")

In cmd you'll need help from PowerShell, or WSH with VBS or Jscript. For example you can save the below code as openFolder.vbs

CreateObject("Shell.Application").Explore(WScript.Arguments.Item(0))

then run openFolder.vbs C:\Users in cmd. You can also use a hybrid batch/VBS or batch/Jscript that you can save as openFolder.bat and call it like openFolder C:\Users

@if (@CodeSection == @Batch) @then
@echo off
cscript //e:jscript //nologo "%~f0" %*
exit /b
@end

// JScript Section
(new ActiveXObject("shell.application")).Explore(WScript.Arguments.Item(0));

Of course you can also save the last line above as openFolder.js and call it the same way


For Windows 10 for some reason Open() or Explore() doesn't work and still focuses on the currently opened window, so you'll have to open some folder that isn't opened at the moment, then Navigate() that window to the desired folder

# Create the shell object
$s = New-Object -ComObject Shell.Application

# Open a random folder that's not opened in Explorer
# I choose Control Panel (0x03/::{26EE0668-A00A-44D7-9371-BEB064C98683}\0)
# for simplicity
$s.Open(0x03)

# Wait for the folder to open. You may need to increase the delay
# if your CPU is slow or under high load
sleep 1
$openedPath = "::{26EE0668-A00A-44D7-9371-BEB064C98683}\0"

# Find the folder we've just previously opened
foreach ($win in $s.Windows()) {
    if ($win.Document.Folder.Self.Path -ieq $openedPath) {
        # Got the newly opened window, now we navigate it away
        $win.Navigate("C:\Users"); break
    }
}

For VBS or Jscript do the same

phuclv
  • 26,555
  • 15
  • 113
  • 235
  • As written, this runs into the same problem the OP had: if an Explorer window is already open to `C:\Users`, this code will activate the existing window rather than opening a second one. I ran into the same problem writing a PowerShell script to save and restore open Explorer windows when restarting the Shell. To overcome this, I opted to open each window by first opening to a system folder that is present in the Desktop namespace but not visible for browsing: `shell:::{5b934b42-522b-4c34-bbfe-37a3ef7b9c90}`, and then navigationg to the desired folder. – Keith Miller May 14 '22 at 03:59
  • @KeithMiller that's not true. A new explorer window will open every time I run the above command in my environment. The old windows isn't focused like when one runs `start \\path` – phuclv May 14 '22 at 04:24
  • Ahhh....OK. Here at least, the behavior depends on the current state. If I open Explorer normally via mouse/keyboard and navigate to `C:\Users` and then run the code, it activates the existing window (repeatedly). If *no* Explorer windows are open, the code will open a new window each time. If you open your first window "manually", do you see the behavior I described? – Keith Miller May 14 '22 at 05:01
  • @KeithMiller I've checked on a Windows 10 machine and indeed the behavior was different. So I've added another solution for Windows 10 above – phuclv May 14 '22 at 05:53