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?


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

start "" "My text file.txt"

(The first empty parameter is often required.)

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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