How to use .bat to open default program?

Welcome to Programming Tutorial official website. Today - we are going to cover how to solve / find the solution of this error How to use .bat to open default program? on this date .

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?

Answer

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

start "" "My text file.txt"

(The first empty parameter is often required.)