On Mac OS X and GNOME on Linux, there are commands that can be used to open files from the command line in their associated GUI editors: open and gnome-open, respectively. Is there any command like this for Windows?

  • @badp: I mentioned "GNOME on Linux" not just Linux.
    – Wuffers
    Commented Feb 17, 2011 at 2:33
  • Whoops, sorry.
    – badp
    Commented Feb 17, 2011 at 2:34
  • @badp: No worries. ;)
    – Wuffers
    Commented Feb 17, 2011 at 2:35
  • xdg-open is the more universal Linux example, if anybody cares
    – furicle
    Commented Feb 21, 2018 at 20:08

9 Answers 9


If you are currently in the command prompt and have a file called test.png and , which are located in c:\test you can do the following:

If you are at the directory (so should say c:\test>) just type:


which would open test in the default png picture editor.

If the files name contains spaces, then simply enclose the file name within " "

 "this image.png"

You can alternatively type:


which will open the file no matter where you currently are.

Finally, you can pass the picture to another program. For example, if you have an image editor called imageedit.exe and it supports opening files through command lines (and if the program is pathed/accessible or you are in it's current directory), you can type the following:

 imageedit c:\test\test.png
  • Just curious: is there also a way to close files or programs or windows through command prompt? Commented May 13, 2017 at 2:29
  • @MilesJohnson only by calling other tools such as taskkill.exe Commented May 29, 2017 at 8:40
  • 3
    works from cmd, but not from PowerShell or Git Bash - explorer is the more universal way
    – furicle
    Commented Feb 21, 2018 at 20:10
  • It's interesting to know that this works for sure! That said, I don't like it! It would be quite confusing to see just a png filename listed as a "command" in a script when you aren't aware of this trick. It would appear like someone screwed up and forgot the executable name they meant to invoke.
    – BuvinJ
    Commented Jun 9, 2022 at 15:23

If it is a registered extension, you can use "start" as in

start WordDoc.doc
  • 7
    Good answer for those using Bash or another shell. Commented Mar 18, 2016 at 2:00
  • This is actually the correct answer. It even opens the default browser if you supply a URL.
    – kumarharsh
    Commented Dec 1, 2016 at 9:12
  • 3
    When I enclose the name in quotes, it instead opens a new shell window for some reason.
    – Erhannis
    Commented Apr 18, 2017 at 15:17
  • 7
    As Steven Digby mentions below start's first parameter is the window title so something like start "" WordDoc.doc would work
    – Tony Brix
    Commented Jan 10, 2018 at 20:32
  • 1
    start does different things depending on the shell you use. With Powershell, it invokes Start-Process With cmd it invokes the tradional start With Git Bash, it invokes the cmd Start The cmd Start does not handle network locations. The PowerShell version will, as will 'explorer ' as detailed below.
    – furicle
    Commented Feb 21, 2018 at 20:05

On Windows command-line explorer "<PATH>" will open the file path with Windows default associated programs. This will also handle all URIs ( http:,https:,ftp: ) and other file protocols defined in Windows Operating System. If the file or protocol is not associated with any program then an Open With dialog will show up. If file is not present then default My Documents folder will open up. It can also open executable files ( EXE, BAT files) and shell namespace paths.


explorer "http://www.google.com"- will open http://www.google.com in windows default browser.

explorer "file:///C:\temp\" will open temp directory if present

explorer "file.txt" will open file.txt on the current directory path .i.e. %CD% path

explorer ::{645ff040-5081-101b-9f08-00aa002f954e} will open RecycleBin.

You can refer about explorer's other useful command-line switches here

powershell -c "folder\childfolder\file.txt"

Source: https://technet.microsoft.com/en-us/library/ee176882.aspx

Simple and versatile.


The first parameter of Start is a window title, so if you have a space in the file name, and you type

Start "My File.txt"

you'll get a command line window with "My File.txt" as the title. To get around this use a dummy title,

Start "my title" "My File.txt"

Depending on the file and what application is opened there probably won't be a window to see anyway.

  • 1
    start is a cmd.exe built-in operator. Meaning it is unavailable in exec library calls or in Windows CreateProcess.
    – gavenkoa
    Commented Sep 7, 2021 at 14:54

If you are in PowerShell (at the PS (current-directory)>  prompt), and you want to open a file in the current directory, you may try this .\myfile.ext.  If you are in the Command Prompt, you can accomplish the same result by typing

powershell -c .\myfile.ext

(You must include the .\, as PowerShell doesn’t load files from the current location by default.)  Or you can provide a directory name (relative or absolute) if the file isn’t in the current directory.

For the first scenario — if you are in PowerShell — if the filename contains space(s), enclose it in quotes (either kind) and precede it with the & symbol:

PS C:\Users\myusername\Pictures> &".\funny cat.jpg"

(You may add a space after the & for readability, if you prefer readability, and you may use / instead of \.)  I don’t know how to make this work in the second scenario (in which you are running powershell -c from Command Prompt) if the file or directory name contains space(s) — quotes don’t seem to help.


This may come a bit late, but the correct command for editing a file name in Windows 7 is "write file_name"

This should open up the default text editor and you should be able to edit the file easily

Edit: It seems to open only Wordpad. For me that was the default text editor.

  • Nice trick. It does not start the default text editor however. My default editor for .txt files is Crimson editor, but this command opens Wordpad.
    – Jan Doggen
    Commented Jul 31, 2014 at 18:30
  • Yes, it does so for me too. Wordpad was default for me. Thanks for the update! Regardless, hope this helps the original poster.
    – Coder
    Commented Aug 1, 2014 at 23:01
  • 3
    write is short for write.exe which is the executable file of wordpad. It's stored in C:\windows which is on the %PATH%, therefore it's just the regular way to open a file with wordpad.
    – amenthes
    Commented May 12, 2017 at 8:25

Specific executable with specific file:

Git Bash Script On Windows 10 :




This example opens the file denoted by $FILE_PATH with the executable denoted by $EXEC_PATH. If this doesn't work for you, try converting the single slash ( "\" ) into double slashes ( "\\" ) for the paths.


In the Windows command prompt, you can run

edit [file_name]

in order to view batch files/logs/text files etc. This command requires QBASIC.EXE, which is by default present in Windows.

See here for other useful MS-DOS commands.

  • 2
    Doesn't seem to work on Windows 7 64-bit, neither edit nor qbasic.exe are recognised. Also, this only works with plain text files.
    – Indrek
    Commented Sep 10, 2012 at 7:06
  • @Indrek, Not recognized on Win8 too.
    – Pacerier
    Commented Mar 20, 2015 at 7:31
  • Modern Windows command line is NOT DOS.
    – oldherl
    Commented Jun 11, 2019 at 11:16

You must log in to answer this question.

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