Open text file and program shortcut in a Windows b

2019-01-22 06:15发布

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"

11条回答
太酷不给撩
2楼-- · 2019-01-22 06:21

Try using:

@ECHO off
ECHO Hello World!

START /MAX D:\SA\pro\hello.txt
查看更多
冷血范
3楼-- · 2019-01-22 06:22

"location of notepad file" > notepad Filename

C:\Users\Desktop\Anaconda> notepad myfile

works for me! :)

查看更多
【Aperson】
4楼-- · 2019-01-22 06:23

The command start [filename] opened the file in my default text editor.

This command also worked for opening a non-.txt file.

查看更多
我欲成王,谁敢阻挡
5楼-- · 2019-01-22 06:25

You can also do:

start notepad "C:\Users\kemp\INSTALL\Text1.txt"

The C:\Users\kemp\Install\ is your PATH. The Text1.txt is the FILE.

查看更多
别忘想泡老子
6楼-- · 2019-01-22 06:32

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"
查看更多
爷的心禁止访问
7楼-- · 2019-01-22 06:34

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"
查看更多
登录 后发表回答