我使用批处理文件创建另一个批处理文件,其中一些部分从文件中提取,它创建一个长文件。
我需要在文件末尾只添加一个exit
命令。
实际上,完成工作后,创建的批处理文件不会关闭。
代码文件创建另一个批处理文件:
:: 'Create Batch File'
@echo off
(for /f "usebackq delims=" %%a in ("D:\Programmi Installati\list.csv") > do (
echo PING -n %%~NXa localhost ^>NUL 2^>^&1
echo/
echo/
)) > "D:\Programmi Installati\new.bat"
new.bat的实际结果(错误):
PING -n 10 localhost >NUL 2>&1
exit
PING -n 15 localhost >NUL 2>&1
exit
PING -n 20 localhost >NUL 2>&1
exit
PING -n 25 localhost >NUL 2>&1
exit
qazxsw poi的预期结果(所需):
new.bat
实际上,除了你的代码中的拼写错误,你在代码块的末尾错过了PING -n 10 localhost >NUL 2>&1
PING -n 15 localhost >NUL 2>&1
PING -n 20 localhost >NUL 2>&1
PING -n 25 localhost >NUL 2>&1
exit
echo
。修复后,您的代码应如下所示:
exit