我从注册表中获取InetSrv文件夹的路径并持久保存在本地变量中。 现在,当对该已保存变量尝试更改目录命令(CD)时,则抛出错误。
@echo off
SETLOCAL
set vb_path=""
for /f "tokens=1-2*" %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp" /v InstallPath') do (set vb_path=%%C)
echo %vb_path%
cd %vb_path%
ENDLOCAL
输出
%windir%\system32\inetsrv
The system cannot find the path specified.
答案 0 :(得分:1)
使用CALL set "vb_path=%%C"
。
这会扩展%windir%
%windir%\system32\inetsrv
部分
@echo off
SETLOCAL EnableExtensions
set "vb_path="
for /f "tokens=1-2*" %%A in ('
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp" /v InstallPath
') do (CALL set "vb_path=%%C")
echo %vb_path%
cd %vb_path%
ENDLOCAL