Open file from the command line on Windows












57















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?










share|improve this question























  • @badp: I mentioned "GNOME on Linux" not just Linux.

    – Wuffers
    Feb 17 '11 at 2:33











  • Whoops, sorry.

    – badp
    Feb 17 '11 at 2:34











  • @badp: No worries. ;)

    – Wuffers
    Feb 17 '11 at 2:35











  • xdg-open is the more universal Linux example, if anybody cares

    – furicle
    Feb 21 '18 at 20:08
















57















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?










share|improve this question























  • @badp: I mentioned "GNOME on Linux" not just Linux.

    – Wuffers
    Feb 17 '11 at 2:33











  • Whoops, sorry.

    – badp
    Feb 17 '11 at 2:34











  • @badp: No worries. ;)

    – Wuffers
    Feb 17 '11 at 2:35











  • xdg-open is the more universal Linux example, if anybody cares

    – furicle
    Feb 21 '18 at 20:08














57












57








57


9






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?










share|improve this question














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?







windows command-line






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 17 '11 at 2:30









WuffersWuffers

13.6k1278117




13.6k1278117













  • @badp: I mentioned "GNOME on Linux" not just Linux.

    – Wuffers
    Feb 17 '11 at 2:33











  • Whoops, sorry.

    – badp
    Feb 17 '11 at 2:34











  • @badp: No worries. ;)

    – Wuffers
    Feb 17 '11 at 2:35











  • xdg-open is the more universal Linux example, if anybody cares

    – furicle
    Feb 21 '18 at 20:08



















  • @badp: I mentioned "GNOME on Linux" not just Linux.

    – Wuffers
    Feb 17 '11 at 2:33











  • Whoops, sorry.

    – badp
    Feb 17 '11 at 2:34











  • @badp: No worries. ;)

    – Wuffers
    Feb 17 '11 at 2:35











  • xdg-open is the more universal Linux example, if anybody cares

    – furicle
    Feb 21 '18 at 20:08

















@badp: I mentioned "GNOME on Linux" not just Linux.

– Wuffers
Feb 17 '11 at 2:33





@badp: I mentioned "GNOME on Linux" not just Linux.

– Wuffers
Feb 17 '11 at 2:33













Whoops, sorry.

– badp
Feb 17 '11 at 2:34





Whoops, sorry.

– badp
Feb 17 '11 at 2:34













@badp: No worries. ;)

– Wuffers
Feb 17 '11 at 2:35





@badp: No worries. ;)

– Wuffers
Feb 17 '11 at 2:35













xdg-open is the more universal Linux example, if anybody cares

– furicle
Feb 21 '18 at 20:08





xdg-open is the more universal Linux example, if anybody cares

– furicle
Feb 21 '18 at 20:08










9 Answers
9






active

oldest

votes


















57














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:



test.png


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:



c:testtest.png


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:testtest.png





share|improve this answer


























  • Just curious: is there also a way to close files or programs or windows through command prompt?

    – Miles Johnson
    May 13 '17 at 2:29











  • @MilesJohnson only by calling other tools such as taskkill.exe

    – William Hilsum
    May 29 '17 at 8:40











  • works from cmd, but not from PowerShell or Git Bash - explorer is the more universal way

    – furicle
    Feb 21 '18 at 20:10











  • Your answer saved my life ^^ thanks!!

    – C-Star-Puppy
    Mar 23 '18 at 23:14



















42














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



start WordDoc.doc





share|improve this answer





















  • 4





    Good answer for those using Bash or another shell.

    – Yves Junqueira
    Mar 18 '16 at 2:00











  • This is actually the correct answer. It even opens the default browser if you supply a URL.

    – kumar_harsh
    Dec 1 '16 at 9:12











  • When I enclose the name in quotes, it instead opens a new shell window for some reason.

    – Erhannis
    Apr 18 '17 at 15:17






  • 1





    As Steven Digby mentions below start's first parameter is the window title so something like start "" WordDoc.doc would work

    – Tony Brix
    Jan 10 '18 at 20:32











  • 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
    Feb 21 '18 at 20:05





















8














On DOS 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.



Examples



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






share|improve this answer































    3














    powershell -c "folderchildfolderfile.txt"


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



    Simple and versatile.






    share|improve this answer


























    • Looks good to me.

      – DavidPostill
      Mar 9 '16 at 21:04











    • @DavidPostill would you consider my answer as useful?

      – Eric
      Mar 9 '16 at 21:05











    • Yes. Have a +1 ;)

      – DavidPostill
      Mar 9 '16 at 21:13



















    1














    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.






    share|improve this answer































      1














      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:UsersmyusernamePictures> &".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.






      share|improve this answer

































        0














        Specific executable with specific file:



        Git Bash Script On Windows 10 :





        SHORTCUTS_MAIN_START.sh :



            FILE_PATH="C:DEVREPOGITAHK03SHORTCUTSSHORTCUTS_MAIN.ahk"
        EXEC_PATH="C:DEVREPOGITAHK03AHK_ROOTAutoHotkeyU64.exe"

        $EXEC_PATH $FILE_PATH




        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.






        share|improve this answer































          -1














          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.






          share|improve this answer


























          • 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
            Jul 31 '14 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
            Aug 1 '14 at 23:01






          • 2





            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
            May 12 '17 at 8:25



















          -3














          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.






          share|improve this answer





















          • 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
            Sep 10 '12 at 7:06











          • @Indrek, Not recognized on Win8 too.

            – Pacerier
            Mar 20 '15 at 7:31











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f246825%2fopen-file-from-the-command-line-on-windows%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          9 Answers
          9






          active

          oldest

          votes








          9 Answers
          9






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          57














          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:



          test.png


          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:



          c:testtest.png


          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:testtest.png





          share|improve this answer


























          • Just curious: is there also a way to close files or programs or windows through command prompt?

            – Miles Johnson
            May 13 '17 at 2:29











          • @MilesJohnson only by calling other tools such as taskkill.exe

            – William Hilsum
            May 29 '17 at 8:40











          • works from cmd, but not from PowerShell or Git Bash - explorer is the more universal way

            – furicle
            Feb 21 '18 at 20:10











          • Your answer saved my life ^^ thanks!!

            – C-Star-Puppy
            Mar 23 '18 at 23:14
















          57














          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:



          test.png


          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:



          c:testtest.png


          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:testtest.png





          share|improve this answer


























          • Just curious: is there also a way to close files or programs or windows through command prompt?

            – Miles Johnson
            May 13 '17 at 2:29











          • @MilesJohnson only by calling other tools such as taskkill.exe

            – William Hilsum
            May 29 '17 at 8:40











          • works from cmd, but not from PowerShell or Git Bash - explorer is the more universal way

            – furicle
            Feb 21 '18 at 20:10











          • Your answer saved my life ^^ thanks!!

            – C-Star-Puppy
            Mar 23 '18 at 23:14














          57












          57








          57







          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:



          test.png


          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:



          c:testtest.png


          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:testtest.png





          share|improve this answer















          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:



          test.png


          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:



          c:testtest.png


          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:testtest.png






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 19 '12 at 16:04









          Community

          1




          1










          answered Feb 17 '11 at 2:38









          William HilsumWilliam Hilsum

          108k16160253




          108k16160253













          • Just curious: is there also a way to close files or programs or windows through command prompt?

            – Miles Johnson
            May 13 '17 at 2:29











          • @MilesJohnson only by calling other tools such as taskkill.exe

            – William Hilsum
            May 29 '17 at 8:40











          • works from cmd, but not from PowerShell or Git Bash - explorer is the more universal way

            – furicle
            Feb 21 '18 at 20:10











          • Your answer saved my life ^^ thanks!!

            – C-Star-Puppy
            Mar 23 '18 at 23:14



















          • Just curious: is there also a way to close files or programs or windows through command prompt?

            – Miles Johnson
            May 13 '17 at 2:29











          • @MilesJohnson only by calling other tools such as taskkill.exe

            – William Hilsum
            May 29 '17 at 8:40











          • works from cmd, but not from PowerShell or Git Bash - explorer is the more universal way

            – furicle
            Feb 21 '18 at 20:10











          • Your answer saved my life ^^ thanks!!

            – C-Star-Puppy
            Mar 23 '18 at 23:14

















          Just curious: is there also a way to close files or programs or windows through command prompt?

          – Miles Johnson
          May 13 '17 at 2:29





          Just curious: is there also a way to close files or programs or windows through command prompt?

          – Miles Johnson
          May 13 '17 at 2:29













          @MilesJohnson only by calling other tools such as taskkill.exe

          – William Hilsum
          May 29 '17 at 8:40





          @MilesJohnson only by calling other tools such as taskkill.exe

          – William Hilsum
          May 29 '17 at 8:40













          works from cmd, but not from PowerShell or Git Bash - explorer is the more universal way

          – furicle
          Feb 21 '18 at 20:10





          works from cmd, but not from PowerShell or Git Bash - explorer is the more universal way

          – furicle
          Feb 21 '18 at 20:10













          Your answer saved my life ^^ thanks!!

          – C-Star-Puppy
          Mar 23 '18 at 23:14





          Your answer saved my life ^^ thanks!!

          – C-Star-Puppy
          Mar 23 '18 at 23:14













          42














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



          start WordDoc.doc





          share|improve this answer





















          • 4





            Good answer for those using Bash or another shell.

            – Yves Junqueira
            Mar 18 '16 at 2:00











          • This is actually the correct answer. It even opens the default browser if you supply a URL.

            – kumar_harsh
            Dec 1 '16 at 9:12











          • When I enclose the name in quotes, it instead opens a new shell window for some reason.

            – Erhannis
            Apr 18 '17 at 15:17






          • 1





            As Steven Digby mentions below start's first parameter is the window title so something like start "" WordDoc.doc would work

            – Tony Brix
            Jan 10 '18 at 20:32











          • 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
            Feb 21 '18 at 20:05


















          42














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



          start WordDoc.doc





          share|improve this answer





















          • 4





            Good answer for those using Bash or another shell.

            – Yves Junqueira
            Mar 18 '16 at 2:00











          • This is actually the correct answer. It even opens the default browser if you supply a URL.

            – kumar_harsh
            Dec 1 '16 at 9:12











          • When I enclose the name in quotes, it instead opens a new shell window for some reason.

            – Erhannis
            Apr 18 '17 at 15:17






          • 1





            As Steven Digby mentions below start's first parameter is the window title so something like start "" WordDoc.doc would work

            – Tony Brix
            Jan 10 '18 at 20:32











          • 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
            Feb 21 '18 at 20:05
















          42












          42








          42







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



          start WordDoc.doc





          share|improve this answer















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



          start WordDoc.doc






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 18 '12 at 3:13









          Tom Wijsman

          50.3k23164247




          50.3k23164247










          answered Feb 17 '11 at 2:36









          DennisDennis

          5,3732328




          5,3732328








          • 4





            Good answer for those using Bash or another shell.

            – Yves Junqueira
            Mar 18 '16 at 2:00











          • This is actually the correct answer. It even opens the default browser if you supply a URL.

            – kumar_harsh
            Dec 1 '16 at 9:12











          • When I enclose the name in quotes, it instead opens a new shell window for some reason.

            – Erhannis
            Apr 18 '17 at 15:17






          • 1





            As Steven Digby mentions below start's first parameter is the window title so something like start "" WordDoc.doc would work

            – Tony Brix
            Jan 10 '18 at 20:32











          • 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
            Feb 21 '18 at 20:05
















          • 4





            Good answer for those using Bash or another shell.

            – Yves Junqueira
            Mar 18 '16 at 2:00











          • This is actually the correct answer. It even opens the default browser if you supply a URL.

            – kumar_harsh
            Dec 1 '16 at 9:12











          • When I enclose the name in quotes, it instead opens a new shell window for some reason.

            – Erhannis
            Apr 18 '17 at 15:17






          • 1





            As Steven Digby mentions below start's first parameter is the window title so something like start "" WordDoc.doc would work

            – Tony Brix
            Jan 10 '18 at 20:32











          • 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
            Feb 21 '18 at 20:05










          4




          4





          Good answer for those using Bash or another shell.

          – Yves Junqueira
          Mar 18 '16 at 2:00





          Good answer for those using Bash or another shell.

          – Yves Junqueira
          Mar 18 '16 at 2:00













          This is actually the correct answer. It even opens the default browser if you supply a URL.

          – kumar_harsh
          Dec 1 '16 at 9:12





          This is actually the correct answer. It even opens the default browser if you supply a URL.

          – kumar_harsh
          Dec 1 '16 at 9:12













          When I enclose the name in quotes, it instead opens a new shell window for some reason.

          – Erhannis
          Apr 18 '17 at 15:17





          When I enclose the name in quotes, it instead opens a new shell window for some reason.

          – Erhannis
          Apr 18 '17 at 15:17




          1




          1





          As Steven Digby mentions below start's first parameter is the window title so something like start "" WordDoc.doc would work

          – Tony Brix
          Jan 10 '18 at 20:32





          As Steven Digby mentions below start's first parameter is the window title so something like start "" WordDoc.doc would work

          – Tony Brix
          Jan 10 '18 at 20:32













          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
          Feb 21 '18 at 20:05







          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
          Feb 21 '18 at 20:05













          8














          On DOS 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.



          Examples



          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






          share|improve this answer




























            8














            On DOS 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.



            Examples



            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






            share|improve this answer


























              8












              8








              8







              On DOS 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.



              Examples



              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






              share|improve this answer













              On DOS 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.



              Examples



              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







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jul 7 '17 at 18:17









              lalthomaslalthomas

              22726




              22726























                  3














                  powershell -c "folderchildfolderfile.txt"


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



                  Simple and versatile.






                  share|improve this answer


























                  • Looks good to me.

                    – DavidPostill
                    Mar 9 '16 at 21:04











                  • @DavidPostill would you consider my answer as useful?

                    – Eric
                    Mar 9 '16 at 21:05











                  • Yes. Have a +1 ;)

                    – DavidPostill
                    Mar 9 '16 at 21:13
















                  3














                  powershell -c "folderchildfolderfile.txt"


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



                  Simple and versatile.






                  share|improve this answer


























                  • Looks good to me.

                    – DavidPostill
                    Mar 9 '16 at 21:04











                  • @DavidPostill would you consider my answer as useful?

                    – Eric
                    Mar 9 '16 at 21:05











                  • Yes. Have a +1 ;)

                    – DavidPostill
                    Mar 9 '16 at 21:13














                  3












                  3








                  3







                  powershell -c "folderchildfolderfile.txt"


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



                  Simple and versatile.






                  share|improve this answer















                  powershell -c "folderchildfolderfile.txt"


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



                  Simple and versatile.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 9 '16 at 20:58

























                  answered Feb 4 '16 at 2:47









                  EricEric

                  314




                  314













                  • Looks good to me.

                    – DavidPostill
                    Mar 9 '16 at 21:04











                  • @DavidPostill would you consider my answer as useful?

                    – Eric
                    Mar 9 '16 at 21:05











                  • Yes. Have a +1 ;)

                    – DavidPostill
                    Mar 9 '16 at 21:13



















                  • Looks good to me.

                    – DavidPostill
                    Mar 9 '16 at 21:04











                  • @DavidPostill would you consider my answer as useful?

                    – Eric
                    Mar 9 '16 at 21:05











                  • Yes. Have a +1 ;)

                    – DavidPostill
                    Mar 9 '16 at 21:13

















                  Looks good to me.

                  – DavidPostill
                  Mar 9 '16 at 21:04





                  Looks good to me.

                  – DavidPostill
                  Mar 9 '16 at 21:04













                  @DavidPostill would you consider my answer as useful?

                  – Eric
                  Mar 9 '16 at 21:05





                  @DavidPostill would you consider my answer as useful?

                  – Eric
                  Mar 9 '16 at 21:05













                  Yes. Have a +1 ;)

                  – DavidPostill
                  Mar 9 '16 at 21:13





                  Yes. Have a +1 ;)

                  – DavidPostill
                  Mar 9 '16 at 21:13











                  1














                  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.






                  share|improve this answer




























                    1














                    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.






                    share|improve this answer


























                      1












                      1








                      1







                      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.






                      share|improve this answer













                      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.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jan 27 '17 at 14:27









                      Steven DigbySteven Digby

                      212




                      212























                          1














                          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:UsersmyusernamePictures> &".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.






                          share|improve this answer






























                            1














                            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:UsersmyusernamePictures> &".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.






                            share|improve this answer




























                              1












                              1








                              1







                              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:UsersmyusernamePictures> &".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.






                              share|improve this answer















                              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:UsersmyusernamePictures> &".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.







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Oct 19 '18 at 19:29









                              Scott

                              15.8k113990




                              15.8k113990










                              answered Oct 19 '18 at 14:25









                              andrey.shedkoandrey.shedko

                              1112




                              1112























                                  0














                                  Specific executable with specific file:



                                  Git Bash Script On Windows 10 :





                                  SHORTCUTS_MAIN_START.sh :



                                      FILE_PATH="C:DEVREPOGITAHK03SHORTCUTSSHORTCUTS_MAIN.ahk"
                                  EXEC_PATH="C:DEVREPOGITAHK03AHK_ROOTAutoHotkeyU64.exe"

                                  $EXEC_PATH $FILE_PATH




                                  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.






                                  share|improve this answer




























                                    0














                                    Specific executable with specific file:



                                    Git Bash Script On Windows 10 :





                                    SHORTCUTS_MAIN_START.sh :



                                        FILE_PATH="C:DEVREPOGITAHK03SHORTCUTSSHORTCUTS_MAIN.ahk"
                                    EXEC_PATH="C:DEVREPOGITAHK03AHK_ROOTAutoHotkeyU64.exe"

                                    $EXEC_PATH $FILE_PATH




                                    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.






                                    share|improve this answer


























                                      0












                                      0








                                      0







                                      Specific executable with specific file:



                                      Git Bash Script On Windows 10 :





                                      SHORTCUTS_MAIN_START.sh :



                                          FILE_PATH="C:DEVREPOGITAHK03SHORTCUTSSHORTCUTS_MAIN.ahk"
                                      EXEC_PATH="C:DEVREPOGITAHK03AHK_ROOTAutoHotkeyU64.exe"

                                      $EXEC_PATH $FILE_PATH




                                      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.






                                      share|improve this answer













                                      Specific executable with specific file:



                                      Git Bash Script On Windows 10 :





                                      SHORTCUTS_MAIN_START.sh :



                                          FILE_PATH="C:DEVREPOGITAHK03SHORTCUTSSHORTCUTS_MAIN.ahk"
                                      EXEC_PATH="C:DEVREPOGITAHK03AHK_ROOTAutoHotkeyU64.exe"

                                      $EXEC_PATH $FILE_PATH




                                      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.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Sep 19 '17 at 16:16









                                      J MADISONJ MADISON

                                      1494




                                      1494























                                          -1














                                          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.






                                          share|improve this answer


























                                          • 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
                                            Jul 31 '14 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
                                            Aug 1 '14 at 23:01






                                          • 2





                                            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
                                            May 12 '17 at 8:25
















                                          -1














                                          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.






                                          share|improve this answer


























                                          • 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
                                            Jul 31 '14 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
                                            Aug 1 '14 at 23:01






                                          • 2





                                            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
                                            May 12 '17 at 8:25














                                          -1












                                          -1








                                          -1







                                          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.






                                          share|improve this answer















                                          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.







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited Aug 1 '14 at 23:00

























                                          answered Jul 31 '14 at 18:11









                                          CoderCoder

                                          12




                                          12













                                          • 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
                                            Jul 31 '14 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
                                            Aug 1 '14 at 23:01






                                          • 2





                                            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
                                            May 12 '17 at 8:25



















                                          • 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
                                            Jul 31 '14 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
                                            Aug 1 '14 at 23:01






                                          • 2





                                            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
                                            May 12 '17 at 8:25

















                                          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
                                          Jul 31 '14 at 18:30





                                          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
                                          Jul 31 '14 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
                                          Aug 1 '14 at 23:01





                                          Yes, it does so for me too. Wordpad was default for me. Thanks for the update! Regardless, hope this helps the original poster.

                                          – Coder
                                          Aug 1 '14 at 23:01




                                          2




                                          2





                                          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
                                          May 12 '17 at 8:25





                                          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
                                          May 12 '17 at 8:25











                                          -3














                                          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.






                                          share|improve this answer





















                                          • 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
                                            Sep 10 '12 at 7:06











                                          • @Indrek, Not recognized on Win8 too.

                                            – Pacerier
                                            Mar 20 '15 at 7:31
















                                          -3














                                          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.






                                          share|improve this answer





















                                          • 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
                                            Sep 10 '12 at 7:06











                                          • @Indrek, Not recognized on Win8 too.

                                            – Pacerier
                                            Mar 20 '15 at 7:31














                                          -3












                                          -3








                                          -3







                                          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.






                                          share|improve this answer















                                          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.







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited Oct 2 '12 at 10:25









                                          Dave

                                          23.3k74363




                                          23.3k74363










                                          answered Sep 10 '12 at 6:54









                                          phoenix079phoenix079

                                          11




                                          11








                                          • 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
                                            Sep 10 '12 at 7:06











                                          • @Indrek, Not recognized on Win8 too.

                                            – Pacerier
                                            Mar 20 '15 at 7:31














                                          • 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
                                            Sep 10 '12 at 7:06











                                          • @Indrek, Not recognized on Win8 too.

                                            – Pacerier
                                            Mar 20 '15 at 7:31








                                          2




                                          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
                                          Sep 10 '12 at 7:06





                                          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
                                          Sep 10 '12 at 7:06













                                          @Indrek, Not recognized on Win8 too.

                                          – Pacerier
                                          Mar 20 '15 at 7:31





                                          @Indrek, Not recognized on Win8 too.

                                          – Pacerier
                                          Mar 20 '15 at 7:31


















                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Super User!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f246825%2fopen-file-from-the-command-line-on-windows%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Сан-Квентин

                                          8-я гвардейская общевойсковая армия

                                          Алькесар