Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Coming from Mac OS X, you can type:

open yourfilehere.txt

and your file will open just as if you had opened it from Finder.

On Windows, I'd like to be able to open files in the same manner. What's the command?

share|improve this question

5 Answers 5

up vote 4 down vote accepted

Just drop the 'open' and you're set.

Enter the filename and it will open with the appropriate program.

You'll need to consider the path to the file, so executing the above would only work if the file is within the current directory.

share|improve this answer
    
this is the easiest way, thanks! –  jweede Sep 10 '09 at 12:57

While just typing the name is shorter, the start command jweede points out is better if you want to open a directory in Explorer instead (like open directoryName opens a folder in finder on OSX).

I use "start ." all the time.

However, you don't need the extra syntax he showed. Just start fileName works fine. The first "" is for the title, which is optional anyway.

share|improve this answer
    
sometimes this is needed for when filenames have spaces in them –  jweede Sep 10 '09 at 13:13
    
The second set of quotes might be needed, but the first ones aren't. So you might do: <code>start "directory name contains spaces"</code>, but you don't need: <code>start "" "directory name contains spaces"</code>. –  Jordan Sep 10 '09 at 13:35
1  
D'oh! Nevermind, looks like I'm wrong. I see what you mean. –  Jordan Sep 10 '09 at 13:38

A few more options to consider.

  1. if you know the name of the application that you want to open the file with you can append the program name before the file: eg. "notepad yourfilehere.txt" or "wordpad yourfilehere.txt". As mentioned above you must be in the files directory for this to work, alternatively eg. "notepad C:\PathTo\YourFile\yourfilehere.txt" and the program that you're trying to launch must be a system application or be added to the PATH system variable
  2. you could use an application launcher program. This technically isn't going to let you open a file from a command line but programs such as Launchy Colibri and FARR enable you to access the programs that open the files much more easily.
share|improve this answer
    
Launchy makes windows life much more bearable. –  jweede Sep 10 '09 at 13:16

% rundll32 url.dll,FileProtocolHandler xyz.bar

why not use "start /c" as mentioned above? because if the xyz.bar is missing the executable flag, you will get something like "access denied". this is also true for one of the answers to 'just drop the "open" term and the shell will handle the rest'

and as i learned right now, 'cygstart' does an excellent job on cygwin as well (see http://superuser.com/questions/38984)

share|improve this answer
    
cygstart is excellent. I usually just make an alias for it to open. So I can simply open x just like I'm used to on the mac. –  jweede Mar 26 '10 at 14:06

In addition to the easy way that Luke pointed out, there's also the start command:

> start yourfilehere.txt

but watch out, if your filename has spaces in it, you'll need to do this:

> start "" "your file here.txt"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.