『第 2 楼』:
使用 LLM 解释/回答一下
请注意,Start会开启新窗口来运行程序,如果新窗口不正常退出,你的批处理就不能正常执行下去,所以如果你要用Start启用dir命令,一定要将dir命令写入一个批处理文件中,然后在批处理文件的最后面加上exit命令。
正确的用法应该是这样:
1、建立使用dir命令的批处理如test.bat:
@echo off
dir c:\
rem ....其它操作
exit
2、在另一个批处理中调用该批处理:
...
start /wait call test.bat
...
其实在这里就没有必要使用start /wait了,因为使用了call命令后,test.bat已经控制了流程,一定是在call结束后才会继续下一步的操作。
Start语法:
启动另一个窗口运行指定的程序或命令。
START
"title" 在窗口标题栏中显示的标题。
path 起始目录
B 在不创建新窗口的情况下开始应用程序。除非
启动 ^C 处理,否则该应用程序会忽略 ^C 处理;
^Break 是唯一可以中断该应用程序的方式
I 新环境是传递给 cmd.exe 的原始环境,
而不是当前环境
MIN 开始时窗口最小化
MAX 开始时窗口最大化
SEPARATE 在分开的内存空间内开始 16 位 Windows 程序
SHARED 在共享内存空间内开始 16 位 Windows 程序
LOW 在 IDLE 优先级类别开始应用程序
NORMAL 在 NORMAL 优先级类别开始应用程序
HIGH 在 HIGH 优先级类别开始应用程序
REALTIME 在 REALTIME 优先级类别开始应用程序
ABOVENORMAL 在 ABOVENORMAL 优先级类别开始应用程序
BELOWNORMAL 在 BELOWNORMAL 优先级类别开始应用程序
WAIT 启动应用程序并等候它结束
command/program
如果是内部 cmd 命令或批文件,那么该命令处理器是
用 /K 命令行开关运行 cmd.exe 的。这表示该窗口在命令运行
后仍然存在。
如果不是内部 cmd 命令或批文件,则是一个程序,并
作为窗口应用程序或控制台应用程序运行。
parameters 这些为传送到命令/程序的参数
如果命令扩展被启用,通过命令行或 START 命令的外部命令
调用会如下改变:
将文件名作为命令键入,非可执行文件可以通过文件关联调用。
(例如,WORD.DOC 会调用跟 .DOC 文件扩展名关联的应用程序)。
关于如何从命令脚本内部创建这些关联,请参阅 ASSOC 和
FTYPE 命令。
执行的应用程序是 32-位 GUI 应用程序时,CMD.EXE 不等应用
程序终止就返回命令提示符。如果在命令脚本内执行,该新行为
则不会发生。
如果执行的命令行的第一个符号是不带扩展名或路径修饰符的
字符串 "CMD","CMD" 会被 COMSPEC 变量的数值所替换。这
防止从当前目录提取 CMD.EXE。
如果执行的命令行的第一个符号没有扩展名,CMD.EXE 会使用
PATHEXT 环境变量的数值来决定要以什么顺序寻找哪些扩展
名。PATHEXT 变量的默认值是:
.COM;.EXE;.BAT;.CMD
请注意,该语法跟 PATH 变量的一样,分号隔开不同的元素。
查找可执行文件时,如果没有相配的扩展名,看一看该名称是否
与目录名相配。如果确实如此,START 会在那个路径上调用
Explorer。如果从命令行执行,则等同于对那个路径作 CD /D。
Please note that Start will open a new window to run the program. If the new window does not exit normally, your batch processing will not be able to execute normally. Therefore, if you use Start to enable the dir command, you must write the dir command into a batch processing file, and add the exit command at the end of the batch processing file.
The correct usage should be like this:
1. Create a batch processing using the dir command such as test.bat:
@echo off
dir c:\
rem ....Other operations
exit
2. Call this batch processing in another batch processing:
...
start /wait call test.bat
...
In fact, there is no need to use start /wait here, because after using the call command, test.bat has controlled the process, and it will definitely continue to the next operation after the call ends.
Start syntax:
Start another window to run the specified program or command.
START
"title" The title displayed in the window title bar.
path Starting directory
B Start the application without creating a new window. Unless
Start ^C processing is enabled, otherwise the application will ignore ^C processing;
^Break is the only way to interrupt the application
I The new environment is the original environment passed to cmd.exe,
instead of the current environment
MIN Minimize the window when starting
MAX Maximize the window when starting
SEPARATE Start 16-bit Windows programs in separate memory spaces
SHARED Start 16-bit Windows programs in shared memory spaces
LOW Start the application in the IDLE priority category
NORMAL Start the application in the NORMAL priority category
HIGH Start the application in the HIGH priority category
REALTIME Start the application in the REALTIME priority category
ABOVENORMAL Start the application in the ABOVENORMAL priority category
BELOWNORMAL Start the application in the BELOWNORMAL priority category
WAIT Start the application and wait for it to end
command/program
If it is an internal cmd command or a batch file, then the command processor is
Run cmd.exe with the /K command line switch. This means that the window remains after the command runs
exist.
If it is not an internal cmd command or a batch file, then it is a program, and
Run as a window application or console application.
parameters These are the parameters passed to the command/program
If command extensions are enabled, external command calls through the command line or START command
The call will change as follows:
Type the file name as a command, and non-executable files can be called through file associations.
(For example, WORD.DOC will call the application associated with the .DOC file extension).
For how to create these associations from inside the command script, see ASSOC and
FTYPE command.
When the executed application is a 32-bit GUI application, CMD.EXE does not wait for the application
The program terminates and returns to the command prompt. If it is executed in a command script, this new behavior
Then it doesn't happen.
If the first symbol of the executed command line is a string "CMD" without extension or path modifier, "CMD" will be replaced by the value of the COMSPEC variable. This
This prevents CMD.EXE from being extracted from the current directory.
If the first symbol of the executed command line has no extension, CMD.EXE will use
The value of the PATHEXT environment variable is used to determine the order in which which extensions
Name. The default value of the PATHEXT variable is:
.COM;.EXE;.BAT;.CMD
Please note that this syntax is the same as the PATH variable, separated by semicolons.
When looking for an executable file, if there is no matching extension, look at whether the name matches
Matches the directory name. If so, START will call Explorer on that path. If executed from the command line, it is equivalent to CD /D on that path.
|