3

NOTE: This is NOT a question about opening a cmd prompt window instance in the current explorer folder path.

I've scoured the internet trying to find an answer to this, but have come up empty. So far, I know I can open new explorer windows under the same explorer process via cmd simply by entering the "explorer" command. But if I type in a folder path, either after the explorer command, or on its own, or after the "start" command, the window takes longer to open, and launches in a new explorer process.

My question is: how do I open a new window at a specific folder path in explorer via cmd prompt under the same process as the currently running explorer.exe instance - basically, the same way I would via ctrl+N from an open explorer window, then entering the path in the address bar, or right-clicking a folder in explorer and selecting "open in new window".

I really hope someone can answer this. I'm sure it's relatively simple, and I've been racking my brain trying to figure it out. Thanks in advance!

6
  • If I type in a folder path it opens in the same Explorer window, which seems different from your experience. Perhaps the difference is in View > Options > Open each folder in the same window. Commented Apr 6, 2022 at 19:02
  • @harrymc no, you missed the part where I said I wanted to use command prompt to launch a new window in explorer, under the same explorer process - not by launching a new explorer process. Not the same as typing a path into the address bar in an explorer window. Commented Apr 6, 2022 at 23:28
  • Why would you want that? Commented Apr 7, 2022 at 7:27
  • Easy enough from PowerShell using the shell.application com object. What has you wedded to cmd.exe? Commented Apr 7, 2022 at 9:53
  • @harrymc TMI to explain here. Suffice it to say it would help relieve some major pains in my workflow. Commented Apr 8, 2022 at 23:12

2 Answers 2

1

Here is one command that you may enter in Explorer that will open the folder C:\Temp in the same instance of explorer.exe:

powershell.exe -command Invoke-Item C:\Temp 

For related reading:

3
  • I'm not at the PC right now to try this, but could I add the same command on several lines (each specifying a different path, and separated by a ping command), and save it as a batch file that I could run to open several new explorer windows under the same process? BTW, nice OG Tron avatar, user! :) Commented Apr 10, 2022 at 23:56
  • 1
    Yes, according to my tests this will work for multiple folders and from a batch file. Commented Apr 11, 2022 at 7:11
  • I can confirm that entering this command in an explorer window will open a new window in the same process at c:\temp (if the folder exists). However, for my purposes, I finally found a solution that accomplishes the task I was originally seeking a solution for. Commented Aug 6, 2024 at 6:04
0

Over 2 years later, I finally figured out how to do what I was originally attempting to do via cmd prompt: restart windows explorer with a default set of open windows, opened in the same order each time, and all under the same explorer instance/process!

Here's the solution, which uses two files (so that there are no cmd windows left open once the process completes), and one shortcut.

Save the following as RestartExplorer.bat on your desktop:

taskkill /F /IM explorer.exe ping -n 2 localhost>nul start "" cmd /c "%userprofile%\Desktop\RunExplorerDefaultWindows.bat" 

Then save this as RunExplorerDefaultWindows.bat on your desktop:

%windir%\explorer.exe ping -n 3 localhost>nul start "" "%userprofile%\Documents" && ping -n 2 localhost>nul && start "" "%userprofile%\Downloads" && ping -n 2 localhost>nul && start "" "%userprofile%\Music" && ping -n 2 localhost>nul && start "" "%userprofile%\Pictures" && ping -n 2 localhost>nul && start "" "%userprofile%\Videos" exit 

Last, make a shortcut to the RestartExplorer.bat file, and in the properties for the shortcut (alt+Enter), click Advanced, and check the Run as administrator box.

To run the process, just double-click on the RestartExplorer.bat shorctut!

I realized that having all of the commands on the same line, each separated by && , would result in each new window being opened under the same instance of explorer, rather than a new explorer instance/process being launched for each window (which happens when using a new line for each start command).

With this, anytime you reach a critical mass of open windows (the point where it becomes hard to find/switch to the one you want), you have a way of quickly reopening a default set of them, and they'll be in the same order on the taskbar every time, thus making it faster and easier to find/switch to the window you want.

And to customize which folders will be opened each time, you can simply change any of the "%userprofile%\folder" paths in the RunExplorerDefaultWindows.bat file to be whichever folder(s) you want for your default set.

2
  • There is likely a simpler way to do this, possibly using only one .bat file, or without needing a shortcut to elevate the privileges of the command prompt when running the process. If anyone can simplify this answer to using just a single .bat file, please do so. Commented Aug 6, 2024 at 9:46
  • Why do your batch file have a ping line in them? I don't see any point to that waste of CPU cycles. Commented Jan 14 at 14:29

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.