我想仅使用cmd.exe(使用ShellExecute,C ++)在文件内编写这样的命令,
就像这样:
timeout /t 10 && start cmd.exe /C "ssh -o ..."
我尝试使用此:
echo timeout /t 10 && start cmd.exe /C "ssh -o ..." > myfile.bat
但是它到达时会减少,&&
并且我不能在整个字符串上使用引号,那我该怎么办?我不想使用cmd.exe以外的任何东西,我只想将此写入.bat
文件。
我该如何解决?
1)使用消失的引号。
FOR %%^" in ("") do (
echo %%~"timeout /t 10 && start cmd.exe /C "ssh -o ..." %%~" > myfile.bat
)
2)转义特殊字符
echo timeout /t 10 ^&^& start cmd.exe /C "ssh -o ..." > myfile.bat
3)使用延迟扩展
setlocal EnableDelayedExpansion
set "line=timeout /t 10 && start cmd.exe /C "ssh -o ...""
echo !line! > myFile
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句