2

所以基本上我想创建一个可以运行用户指定的任何记事本文件的批处理脚本。我试过这个...

@Echo Off
SET /P ANSWER=What is the name of the file to open?  
IF /i (%ANSWER%)==('FIND /i "*.txt" %ANSWER%) (goto :Filename)
goto :exit
:Filename
Start *.txt
EXIT
:exit
ECHO FAILLLLLLLL
PAUSE
EXIT

这里的问题是第一个 IF 语句。我知道它错了。但是,我不知道如何指定任何文件名的条目。还赞赏执行此任务的不同方法。

感谢帮助 :)

4

1 回答 1

2

如果您的目标只是打开用户在记事本中指定的文件,则以下内容适用于 Windows 7:

@echo off

set /P answer=What is the file name? 
if exist %answer% (
    start notepad.exe %answer%
) else (
    echo Unable to locate %answer%
)
于 2012-09-14T15:08:08.867 回答