Open text file and program shortcut in a Windows batch file
Don't put quotes around the name of the file that you are trying to open; start "myfile.txt"
opens a new command prompt with the title myfile.txt
, while start myfile.txt
opens myfile.txt
in Notepad. There's no easy solution in the case where you want to start a console application with a space in its file name, but for other applications, start "" "my file.txt"
works.
This would have worked too. The first quoted pair are interpreted as a window title name in the start command.
start "" "myfile.txt"
start "" "myshortcut.lnk"
I was able to figure out the solution:
start notepad "myfile.txt"
"myshortcut.lnk"
exit