Search code examples
command-linebatch-filecmdcommand-prompt

Open text file and program shortcut in a Windows batch file


I have two files in the same folder that I'd like to run. One is a .txt file, and the other is the program shortcut to an .exe. I'd like to make a batch file in the same location to open the text file and the shortcut then close the batch file (but the text file and program remain open).

I tried this with no luck:

open "myfile.txt"
open "myshortcut.lnk"

Also didn't work:

start "myfile.txt"
start "myshortcut.lnk"

Solution

  • I was able to figure out the solution:

    start notepad "myfile.txt"
    "myshortcut.lnk"
    exit