Open text file and program shortcut in a Windows batch file

后端 未结 12 1353
暗喜
暗喜 2020-12-13 17:59

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

相关标签:
12条回答
  • 2020-12-13 18:36

    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"
    
    0 讨论(0)
  • 2020-12-13 18:37

    Try using:

    @ECHO off
    ECHO Hello World!
    
    START /MAX D:\SA\pro\hello.txt
    
    0 讨论(0)
  • 2020-12-13 18:43

    "location of notepad file" > notepad Filename

    C:\Users\Desktop\Anaconda> notepad myfile

    works for me! :)

    0 讨论(0)
  • 2020-12-13 18:47

    I was able to figure out the solution:

    start notepad "myfile.txt"
    "myshortcut.lnk"
    exit
    
    0 讨论(0)
  • 2020-12-13 18:47

    The command-line syntax for opening a text file is:

    type filename.txt
    

    File types supported by this command include (but are not limited to): .doc, .txt, .html, .log

    If the contents is too long, you can add "|more" after "type filename.txt", and it will pause after each screen; to end the command before the end of the file, you can hold Ctrl + C.

    0 讨论(0)
  • 2020-12-13 18:47

    In some cases, when opening a LNK file it is expecting the end of the application run.

    In such cases it is better to use the following syntax (so you do not have to wait the end of the application):

    START /B /I "MyTitleApp" "myshortcut.lnk"
    

    To open a TXT file can be in the way already indicated (because notepad.exxe not interrupt the execution of the start command)

    START notepad "myfile.txt"
    
    0 讨论(0)
提交回复
热议问题