我从 知道call /?,~in 变量(例如%~d1)用于解析文件路径的一部分(此处为驱动程序),但波浪号在此处的另一个上下文中使用:https ://www.tutorialspoint.com/batch_script/batch_script_string_length.htm :
@echo off
set str = Hello World
call :strLen str strlen
echo String is %strlen% characters long
exit /b
:strLen
setlocal enabledelayedexpansion
:strLen_Loop
if not "!%1:~%len%!"=="" set /A len+=1 & goto :strLen_Loop
(endlocal & set %2=%len%)
goto :eof
Run Code Online (Sandbox Code Playgroud)
这里,这个变量扩展的意义是什么:"!%1:~%len%!"?它如何通过与空字符串比较来计算字符串的长度?这里波浪号的目的是什么?此外,这个例子将使我进入无限循环,其中输出是if not "!str:~136!" == "" set /A len+=1 & goto :strLen_Loop(数字!str:~n增长的地方)。
我可以通过指定其路径来启动 exe:
c:\> "c:\program files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe",现在尝试使用以下命令执行相同操作start:
c:\> start /separate "c:\program files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe"
Run Code Online (Sandbox Code Playgroud)
将仅启动 的另一个实例cmd.exe,但不启动 Visual Studio。有谁知道为什么?