Windows explorer open with folder

Opening a folder in explorer and selecting a file

I’m trying to open a folder in explorer with a file selected.

The following code produces a file not found exception:

How can I get this command to execute in C#?

11 Answers 11

First argument is an application (explorer.exe), second method argument are arguments of the application you run.

If your path contains comma’s, putting quotes around the path will work when using Process.Start(ProcessStartInfo).

It will NOT work when using Process.Start(string, string) however. It seems like Process.Start(string, string) actually removes the quotes inside of your args.

Here is a simple example that works for me.

Just my 2 cents worth, if your filename contains spaces, ie «c:\My File Contains Spaces.txt», you’ll need to surround the filename with quotes otherwise explorer will assume that the othe words are different arguments.

Using Process.Start on explorer.exe with the /select argument oddly only works for paths less than 120 characters long.

I had to use a native windows method to get it to work in all cases:

Samuel Yang answer tripped me up, here is my 3 cents worth.

Adrian Hum is right, make sure you put quotes around your filename. Not because it can’t handle spaces as zourtney pointed out, but because it will recognize the commas (and possibly other characters) in filenames as separate arguments. So it should look as Adrian Hum suggested.

Notice there should be a comma after /select instead of space..

The most possible reason for it not to find the file is the path having spaces in. For example, it won’t find «explorer /select,c:\space space\space.txt».

Just add double quotes before and after the path, like;

or do the same in C# with

You need to put the arguments to pass («/select etc») in the second parameter of the Start method.

It might be a bit of a overkill but I like convinience functions so take this one:

This is the extension function I use as .Quote():

Not the answer you’re looking for? Browse other questions tagged c# explorer or ask your own question.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093

Читайте также:  Все звуки windows через asio

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Open folders in Explorer

Open the current folder in Explorer without the left side explorer bar:

Open any folder in Explorer without the left side explorer bar:

Open the current folder in Explorer with the left side explorer bar:

(Tip: Padmanabha Holla)

This trick with the comma also works for other folders:

The following tip by Peter Lancashire adds some interesting possibilities:

Windows XP adds even more switches for EXPLORER.EXE , as explained in Microsoft KnowledgeBase article 314853:

/N Opens a new single-pane window for the default selection.
This is usually the root of the drive that Windows is installed on.
If the window is already open, a duplicate opens.
/E Opens Windows Explorer in its default view.
/ROOT,object Opens a window view of the specified object.
/SELECT,object Opens a window view with the specified folder, file, or program selected.

As Peter said, the /ROOT switch can be useful in shortcuts, to prevent Explorer from scanning the entire (slow) network.

Compare the result of the following command with the previous one:

And how about selecting a file or folder in the Explorer window:

Unfortunately, the /ROOT switch is ignored if the /SELECT switch is used.

Credentials

Using the explorer command will always open a new instance of the running Explorer (which is Windows’ so called «primary shell»).
This new instance will always use the primary shell’s credentials, i.e. the logged on user’s credentials.

To open an Explorer look-alike with other credentials, we can use Internet Explorer.

Open the current folder in an Explorer look-alike with the credentials of the session that runs this command:

Open the current folder with Administrator credentials:

Note: Depending on the Internet Explorer version, the left side explorer bar may (IE6) or may not (IE7) be visible.

This command won’t work unless you add Internet Explorer’s location to the PATH, or you use the fully qualified path to IEXPLORE.EXE in the command.
With a little help from REG.EXE (code shown is for version 3.0) we can look up Internet Explorer’s location on-the-fly:

Or, if you insist on one-liners:

(note the addition of skip=1 )

Run Explorer in a separate process

Contrary to what I just wrote about a single Explorer process, it is possible to run Explorer as a separate process.

If you want to run each Explorer window in its own separate process, you need to tweak the registry:

By setting the value to 1, each Explorer window will run in a separate process.
This allows you to start an Explorer process with different credentials using the basic RUNAS command.

It works, but I think there is a better solution.

Lately (I cannot find when this feature was introduced, it is available in Windows 7 64-bits), Explorer has a /SEPARATE switch to specify which Explorer window we want to run in a separate process.

Start an Explorer window with Administrator’s credentials:

Open Folder in an Explorer window with Administrator’s credentials:

Folder may be in drive:\folder\subfolder or UNC format.
Mapped network drives, however, usually won’t work because mappings are stored in the user profile.

How to Change File Explorer Default Start Folder in Windows 10

The Windows 10 File Explorer opens to Quick access by default. Quick access is a section where you can place shortcuts to your favorite folders. It also displays recently viewed files and frequently used folders. If you’re not a fan of the Quick access feature and want File Explorer to default to “This PC”, Downloads or any other custom folder by default, this post tells you how to do it.

Читайте также:  Добавить компьютер с windows microsoft

Open File Explorer to This PC or Quick access

  1. Start File Explorer, and click the File menu.
  2. Click Folder and search options
  3. In the Folder Options dialog that opens, select This PC from the drop-down box, and click OK.

There is also another choice (“Downloads”) you can make which Microsoft doesn’t tell you. But it requires editing the registry.

Open File Explorer to the Downloads folder by default

Here is how to set File Explorer to open the “Downloads” folder every time you press WinKey + E or click the File Explorer Taskbar shortcut.

The Folder Options setting “Open File Explorer to:” is saved in the following registry key:

Value name: LaunchTo

Data: 1, 2 or 3

  • 1 – File Explorer opens to “This PC”
  • 2 – File Explorer opens to Quick access
  • 3 – This is undocumented. If the value data is set to 3 (not configurable via Folder Options dialog), File Explorer opens to the Downloads folder.

Launch the Registry Editor ( regedit.exe ) and go to the above key:

Set the LaunchTo value data to 3 and exit the Registry Editor.

Note that after setting the value data to 3 , the drop-down box in the Folder Options dialog would appear like this.

One of the Windows 10 Anniversary Update insider preview builds included “Downloads” in the drop-down list, and Microsoft removed the option in the subsequent releases. However, the registry edit still works in version 1903 through 20H2.

Open File Explorer to Any folder of your choice

To make File Explorer start to a custom folder location other than the three options, use the registry edit and script method described in the article How to Change WinKey + E and File Explorer Shortcut Target in Windows 10

One small request: If you liked this post, please share this?

About the author

Ramesh Srinivasan founded Winhelponline.com back in 2005. He is passionate about Microsoft technologies and he has been a Microsoft Most Valuable Professional (MVP) for 10 consecutive years from 2003 to 2012.

Microsoft → Windows → Windows 10 → How to Change File Explorer Default Start Folder in Windows 10

3 thoughts on “How to Change File Explorer Default Start Folder in Windows 10”

Is there a tweak to have Explorer open with the highlighted folder at the top of the left panel list instead of near the bottom.

Latest Windows 10 registry does not have Launchto.

Tried this today, works as of 2020-10-09. Thanks!

How to Set Win­dows 7 Explor­er to Open Your Favorite Fold­er By Default

Ashish Mundhra

20 Dec 2011

I hardly use the Windows 7 library and hence I find it a bit irritating sometimes that the Windows explorer folder icon on my taskbar opens the Library by default. I mean, I should be able to quickly set it to open my favorite/most frequently used folder, right? Turns out, this isn’t that straight-forward.

If you too don’t use the Windows 7 Library often enough and want to set explorer to open your favorite folder each time then here’s a trick using which you can directly open any drive or folder using the very same Windows Explorer folder on taskbar.

Setting Windows Explorer to Open Your Favorite Folder By Default

Step 1: Browse to the folder that you want to open using the Windows Explorer in the future.

Step 2: Now, click on the address bar to reveal the full address of the folder and copy the address to a temporary text file.

Step 3: Close the directory and right-click on the Windows Explorer folder on the taskbar. Now, again right-click on Windows Explorer written just above the unpin folder option and select properties.

Читайте также:  Как установить virtualbox 64 bit windows

Step 4: In the properties dialog box, hunt for the Target: field to see a text reading %windir%\explorer.exe . Copy and save it to a text file (This is us creating a failsafe if we want to revert back to default settings).

Step 5: Now pay attention! After the %windir%\explorer.exe, give a space then write /e, (with the coma) than again give a space followed by the address of the directory you copied in the step 2.

Click on OK to save your settings.

You can now open any folder of your choice using the above trick but what about opening My Computer or Documents? What are their paths? Well if you want to open My Computer or My Documents directly, just copy and paste the following text in the Target: field

My Computer

My Documents

My Verdict

When I tried the trick on my computer, I noticed a considerable amount of time gap between me clicking the Windows Explorer and opening of the desired folder. After a research of half an hour, I noticed a very unusual thing. The thing is, if you change the shortcut of Windows Explorer from libraries to any other folder of your choice then, each time when you click on it to open the folder, an individual explorer process will start.

I found it a bit irritating but there is nothing we can do about it. However, one workaround is to pin the folder to the taskbar using the Windows 7 Taskbar Items Pinner. It not only fixes the multiple explorer bug but also lets you pin multiple favorite folders. But depending on how you work, there are pros and cons to both the methods so choose accordingly.

Last updated on 8 Feb, 2018
The above article may contain affiliate links which help support Guiding Tech. However, it does not affect our editorial integrity. The content remains unbiased and authentic.

7 Best Ways to Quickly Access Your Most Used Folders on Windows 7

Check Out these 7 Best Ways to Quickly Access Your Most Used Folders on # Windows 7.

Top 13 Ways to Fix Folder Access Denied Error in Windows

Trying to open a folder on # Windows 10 but viewing the access denied pop-up error instead? Here’s a detailed # troubleshooting guide on how to fix this error and regain access.

Top 7 Windows 7 Explorer Tools and Hacks to Make You More Productive

Check out these Top 7 # Windows 7 Explorer Tools and Hacks to Make You More Productive.

Solid Explorer vs FX Explorer: Which Is the Best File Manager

In this guide, we will compare two amazing and feature-rich file managers — Solid Explorer and FX Explorer. Let’s see how they are similar and how they differ.

5 Best Alternatives to Windows 10 Photos App

Is # Windows # Photos app bothering you? Are you looking for alternatives? Here, we bring you 5 alternatives or similar apps to Windows Photos.

15 Awesome Windows Run Commands You Might Not Know About

Ever Knew the Run Box Could be So Useful? Check Out these 15 Awesome # Windows Run Commands You Might Not Know About.

How to Switch the Default Browser in Windows 10 from Edge to Chrome or Firefox

# Windows 10 makes it harder than ever to select a 3rd party # browser as your default. Not to worry, we’re here to help with just that.

How to Disable Fullscreen Optimization in Windows 10

Facing lags while playing games on # Windows 10? Here are the fixes for the Fullscreen Optimizations to get rid of the new borderless display mode.

Did You Know

Most of YouTube’s viewers are smartphone or tablet users.

Оцените статью