1

在 DOS 的 Windows 批处理文件中,我收到以下错误:

45.0.31322.0 unexpected at this time.

数字45.0.31322.0AgtVersion变量的内容。

这是代码:

if agentVersion: 45.0.31322.0==agentVersion: 45.0.31322.0 set AgtVersion=45.0.31322.0

:: Identify HPSA Agent Version
for /f "delims=" %%x in ('get_info.bat ^| find /i "agentVersion: 4"') do @set hpsaAGT=%%x

:: Checks agent version and store in new variable
if %hpsaAGT%==agentVersion: 45.0.31322.0 set AgtVersion=45.0.31322.0

:: THE ERROR HAPPENS HERE:
:: the above line throws a: "45.0.31322.0 unexpected at this time."

if %hpsaAGT%==agentVersion: 40.0.0.1.106 set AgtVersion=40.0.0.1.106
if agentVersion: 45.0.31322.0==agentVersion: 45.0.31322.0 set AgtVersion=45.0.31322.0

:: Display HPSA Agent Version and store in txt file
echo %AgtVersion%> c:\temp\hpsa_agent\hpsaAGT.txt
echo Current HPSA Core : %AgtVersion%

这个错误信息是什么意思?

4

1 回答 1

3

您正在将变量与带有空格的未引用字符串进行比较。DOS 将agentVersion:and解释45.0.31322.0为两个不同的标记。第二个令牌是意外的。

if %hpsaAGT%==agentVersion: 45.0.31322.0 

应该:

if "%hpsaAGT%"=="agentVersion: 45.0.31322.0"
于 2013-03-29T14:56:51.797 回答