使用^符号输入带有参数的多行命令时使用双引号来使用带空格的字符串^符号也会被传递,有人可以解释这是什么方式吗?
working.cmd
@echo off
call openfiles.cmd ^
C:\dir\filename.txt ^
C:\another_dir\another_file.txt
Run Code Online (Sandbox Code Playgroud)
notworking.cmd
@echo off
call openfiles.cmd ^
"C:\dir with spaces\file with spaces.txt" ^
"C:\another dir with spaces\another file with spaces.txt"
Run Code Online (Sandbox Code Playgroud)
openfiles.cmd看起来像
@echo off
for %%x in (%*) do (
IF EXIST %%x (
call "c:\Program Files\Notepad++\notepad++.exe" %%x
) ELSE (
call echo Not found %%x
)
)
pause
Run Code Online (Sandbox Code Playgroud)
我得到的错误
C:\>call openfiles.cmd "C:\dir with spaces\file with spaces.txt" ^
ELSE was unexpected at this time.
Run Code Online (Sandbox Code Playgroud)