1

In a Windows Batch File in DOS, I am receiving the the following error:

45.0.31322.0 unexpected at this time.

The numbers 45.0.31322.0 are the contents of the AgtVersion variable.

Here is the code:

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%

What does this error message mean?

pnuts
  • 56,678
  • 9
  • 81
  • 133
Jimbo Muldy
  • 37
  • 2
  • 6
  • 1
    use double-quotes, if your string contains Spaces: if "%hpsaAGT%"=="agentVersion: 45.0.31322.0" set AgtVersion=45.0.31322.0 – Stephan Mar 29 '13 at 14:29
  • possible duplicate of [%x was unexpected at this time. batch script](http://stackoverflow.com/questions/2190295/x-was-unexpected-at-this-time-batch-script) – Eric Leschinski Mar 29 '13 at 14:39

1 Answers1

3

You are comparing a variable to an unquoted string with spaces on it. DOS interprets the agentVersion: and 45.0.31322.0 as two distinct tokens. The second token is unexpected.

if %hpsaAGT%==agentVersion: 45.0.31322.0 

Should be:

if "%hpsaAGT%"=="agentVersion: 45.0.31322.0"
rojo
  • 23,334
  • 5
  • 52
  • 98
Eric Leschinski
  • 135,913
  • 89
  • 401
  • 325