28

I'm trying to use the start command in the command prompt to open files and folders, but I'm unable to open files and folders that contain space(s) in their name.

I have tried the following queries (testing on C:\Program Files):

start C:\Program Files
start C:/Program\ Files
start C:/"Program Files"
start C:\"Program Files"
start "C:\Program Files"
start "C:/Program Files"
start C:/Program_Files
start C:/Program%20Files

But none of them work.

1
  • 4
    Not strictly speaking the answer you're looking for (hence posted as a comment), but start c:\progra~1 will do the trick.
    – Bryan
    Nov 27, 2012 at 20:21

5 Answers 5

29

You would use:

start "" "c:\program files\"

That is because the first parameter is used as the title of the window, and is oddly enough, enclosed in double quotes.

Edit:

Here is a source about it: SS64

As an example, if you just type start "title" it opens a new cmd window with the title "title" in the title bar.

8
  • 3
    What's with the empty one?
    – Cole Tobin
    Nov 27, 2012 at 20:25
  • 1
    +1; interesting, would love to know how this works?
    – Bryan
    Nov 27, 2012 at 20:26
  • 3
    It's a title for the window, the parameter is enclosed in double quotes for some stupid reason. I rarely use Windows, especially when they do this stuff that makes little sense to me. In linux the CLI would be -t or whatever for title.
    – nerdwaller
    Nov 27, 2012 at 20:27
  • Wow, trust who else but Microsoft to come up with something like that!
    – Bryan
    Nov 27, 2012 at 20:28
  • 2
    Yes, it is obvious why quotations are needed. However, why that is not an optional parameter is not. That's the question.
    – nerdwaller
    Nov 28, 2012 at 1:08
14

Do you specifically need to use start?

You can use explorer "c:\program files" to give you the effect you are looking for.

5
  • 1
    Didn't know about this one. Is there any difference between start and explorer?
    – amiregelz
    Nov 27, 2012 at 20:38
  • Start is built to run a command through, so it would build a window and run a script. Explorer opens explorer, plain and simple.
    – nerdwaller
    Nov 27, 2012 at 20:40
  • This article details some command line switches (work on Win 7, despite it specifying Win XP) that do funky things, such as open an explorer window and highlight a specific file, e.g. explorer /select,c:\Windows\System32\calc.exe
    – Bryan
    Nov 27, 2012 at 20:42
  • 2
    @nerdwaller, explorer, will also launch an app, e.g. explorer c:\Windows\System32\calc.exe.
    – Bryan
    Nov 27, 2012 at 20:43
  • 1
    I apologize for omitting that. Documents and such as well explorer Documents\example.xlsx Thank you for pointing it out! I always wonder how people can work in the normal CMD, after working through the linux terminal... Haha. Autocomplete is a joke for commands...!
    – nerdwaller
    Nov 27, 2012 at 20:45
1

If you are already in the current directory, you could always do this.

C:\>cd "C:\Program Files"

C:\Program Files>start .

C:\Program Files>
1
1

Type cd space and press Tab it will give you the directory items list, simple.

-1

Use url encoding

// assign base path initially from a filename

var basePath = Path.GetDirectoryName(doc.Filename);

this.BaseUri = new Uri($"file:///{basePath}"); // add file:/// prefix

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .