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
  • 30,396
  • 15
  • 136
  • 260
K0SS4
  • 11

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
  • 30,396
  • 15
  • 136
  • 260