0

尝试编辑注册表查询批处理文件以设置注册表条目的路径。尝试运行批处理文件时返回此错误。

如果我在命令提示符中手动输入一个片段,它将完美地读取和设置路径。

B)此时出乎意料

@For /F "Tokens=2* skip=2" B)

SETLOCAL ENABLEEXTENSIONS

:v64bita2
@For /F "Tokens=2* skip=2" %A In ('REG QUERY "HKLM\SOFTWARE\Wow6432Node\Bohemia Interactive Studio\ArmA 2" /v "MAIN"') Do (set ARMA2PATH=%B)
IF NOT DEFINED ARMA2PATH (GOTO v32bita2) ELSE (GOTO v64a2oa)

:v32bita2
@For /F "Tokens=2* skip=2" %C In ('REG QUERY "HKLM\SOFTWARE\Bohemia Interactive Studio\ArmA 2" /v "MAIN"') Do (set ARMA2PATH=%D)
IF NOT DEFINED ARMA2PATH (GOTO uaca2) ELSE (GOTO v64a2oa)

:uaca2
@FOR /F "tokens=2* delims=   " %I IN ('REG QUERY "HKLM\SOFTWARE\Wow6432Node\Bohemia Interactive Studio\ArmA 2" /v "MAIN"') DO (SET ARMA2PATH=%J)
IF NOT DEFINED ARMA2PATH (GOTO stda2) ELSE (GOTO v64a2oa)

:stda2
@FOR /F "tokens=2* delims=   " %K IN ('REG QUERY "HKLM\SOFTWARE\Bohemia Interactive Studio\ArmA 2" /v "MAIN"') DO (SET ARMA2PATH=%L)
IF NOT DEFINED ARMA2PATH (GOTO ENDfailA2) ELSE (GOTO v64a2oa)

:v64a2oa
For /F "Tokens=2* skip=2" %E In ('REG QUERY "HKLM\SOFTWARE\Wow6432Node\Bohemia Interactive Studio\ArmA 2 OA" /v "MAIN"') Do (set ARMA2OAPATH=%F)
IF NOT DEFINED ARMA2OAPATH (GOTO v32a2oa) ELSE (GOTO RUN)

:v32a2oa
For /F "Tokens=2* skip=2" %G In ('REG QUERY "HKLM\SOFTWARE\Bohemia Interactive Studio\ArmA 2 OA" /v "MAIN"') Do set (ARMA2OAPATH=%H)
IF NOT DEFINED ARMA2OAPATH (GOTO uaca2oa) ELSE (GOTO RUN)

:uaca2oa
@FOR /F "tokens=2* delims=   " %M IN ('REG QUERY "HKLM\SOFTWARE\Wow6432Node\Bohemia Interactive Studio\ArmA 2 OA" /v "MAIN"') DO (SET ARMA2OAPATH=%N)
IF NOT DEFINED ARMA2OAPATH (GOTO stda2oa) ELSE (GOTO RUN)

:stda2oa
@FOR /F "tokens=2* delims=   " %O IN ('REG QUERY "HKLM\SOFTWARE\Bohemia Interactive Studio\ArmA 2 OA" /v "MAIN"') DO (SET ARMA2OAPATH=%P)
IF NOT DEFINED ARMA2OAPATH (GOTO ENDfailA2OA) ELSE (GOTO RUN)

ENDLOCAL

:run

title CMG - Mod Downloader

echo .
echo Downloading Mods Now
echo .

:ENDfailA2
echo ArmA 2 Not Installed
pause

:ENDfailA2OA
echo ArmA 2 OA Not Installed
pause
4

1 回答 1

1

在批处理文件中,您必须将%. 例如你的第一行:

@For /F "Tokens=2* skip=2" %%A In ('REG QUERY "HKLM\SOFTWARE\Wow6432Node\Bohemia Interactive Studio\ArmA 2" /v "MAIN"') Do (set ARMA2PATH=%%B)

此外,您可以将第一行设置为

@echo off

那么你不必@在每一行都放一个

于 2013-08-05T05:27:21.710 回答