首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >批处理文件错误,“此时意外”

批处理文件错误,“此时意外”
EN

Stack Overflow用户
提问于 2013-03-29 22:28:06
回答 1查看 4.5K关注 0票数 1

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

代码语言:javascript
复制
45.0.31322.0 unexpected at this time.

数字45.0.31322.0AgtVersion变量的内容。

代码如下:

代码语言:javascript
复制
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%

此错误消息是什么意思?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-29 22:56:52

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

代码语言:javascript
复制
if %hpsaAGT%==agentVersion: 45.0.31322.0 

应该是:

代码语言:javascript
复制
if "%hpsaAGT%"=="agentVersion: 45.0.31322.0"
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15705270

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档