0

Is it possible (using cmd or .bat) to automatically open a text file using the default Windows application?

For example, when opening a .html file, if Chrome is my default browser, the .html will open with Chrome automatically. How can I tell the cmd (or .bat) to open the default program for a particular file extension?

2 Answers 2

2

Use the start command, which I believe uses ShellExecute():

start "" "My text file.txt"

(The first empty parameter is often required.)

2
  • Thanks. What if there's no document? How would I simply open the default web browser or default text editor?
    – user910404
    May 31, 2018 at 9:30
  • @user910404 if this is what you meant to ask in the first place, please edit your question to indicate that. May 31, 2018 at 10:28
2

That is what the START command is for.
START <name of document> will load the document in the default application.

0

You must log in to answer this question.

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