0

I am attempting to get my script to GOTO Manual if the criteria below is not met . How ever if the get_info.bat fails and throws a error my script stops and just displays the batch file error (calling python script) . It works when the condtions are met but not on error / not met.

for /f "tokens=1* delims=" %%x in ('get_info.bat ^| find /i "agentVersion: 4"') do @set HPSAAGT=%%x
ECHO %HPSAAGT%

IF "%HPSAAGT%"=="agentVersion: 45.0.31322.0" (set AGTVERSION=45.0.31322.0) ELSE IF "%HPSAAGT%"=="agentVersion: 40.0.0.1.106" (set AGTVERSION=40.0.0.1.106) ELSE (GOTO MANUAL)
Jimbo Muldy
  • 37
  • 2
  • 6

2 Answers2

0

The code works fine for me... it may be a problem with your variable. Try echo -%HPSAAGT%- to see if there are extra spaces in your variable.

Additionally, if you just want the version number, you should just use string manipulation, example:

echo %HPSAAGT:~14%

would result in

45.0.31322.0
Patrick Meinecke
  • 3,963
  • 2
  • 18
  • 26
  • There are no extra spaces: he said "It works when the condtions are met" – Stephan Apr 11 '13 at 16:24
  • Correct Stephen , Peter = 99/100 it works when the varible equals either of these two below HPSAAGT = agentVersion: 45.0.31322.0 HPSAAGT = agentVersion: 40.0.0.1.106 If get info or get_facility throws an error it should GOTO MANUAL which just calls the manual installer . The Manual installer works the issue I have is the error which doesnt GOTO Label it just stops the script . – Jimbo Muldy Apr 11 '13 at 18:22
  • My mistake, I missed that. @JimboMuldy the code you shared is correct, we cannot troubleshoot without seeing the rest of it. – Patrick Meinecke Apr 11 '13 at 18:54
  • Hm - I see no reason, why the GOTO shouldn't work. Have you verified with a "echo Yes I Jumped" right after the Label :manual ? – Stephan Apr 12 '13 at 16:41
  • @JimboMuldy what do you mean by "throw an error"? Does it even make it to the if else statements? And a sort of silly question but, the `manual` label IS in the same batch file right? – Patrick Meinecke Apr 12 '13 at 17:21
0
if a==b (echo ab) else if b==c (echo bc) else (goto manual)
rem some more code
pause
:manual
echo Manual

works fine.

Is there possibly a misspelling in your Label :manual ?

Stephan
  • 53,940
  • 10
  • 58
  • 91
  • Copied and pasted , retyped and highlighted duplicate varibles in the text editor so . every thing appears to be the same – Jimbo Muldy Apr 11 '13 at 18:34