TimAllan
asked on
Return error code from a fail/successful batch file
I've got a batch file that I'm running under SCCM 2007 that installs the Cisco VPN Client and determines whether or not it's 32 bit or 64 bit. That part works fine.
However, I'd like it to return a 0 error code for success or error code 1 >= if it fails at any stage. At the moment it just returns an error code of 0 so it's telling me it's always successful in SCCM.
Below is the batch file script :
However, I'd like it to return a 0 error code for success or error code 1 >= if it fails at any stage. At the moment it just returns an error code of 0 so it's telling me it's always successful in SCCM.
Below is the batch file script :
Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
REG.exe Query %RegQry% > checkOS.txt
Find /i "x86" < CheckOS.txt > StringCheck.txt
If %ERRORLEVEL% == 0 (
msiexec /i 32bit\vpnclient_setup.msi LAUNCHSETMTU=0 /norestart /qn
) ELSE (
msiexec /i 64bit\vpnclient_setup.msi LAUNCHSETMTU=0 /norestart /qn
)
del checkos.txt /q
del stringcheck.txt /q
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks guys, I used a bit from each of your responses for my solution. great work.
And what about my solution? Ok, I forgot to replace ELSE by ||, but besides that, I cannot see any disadvantages in your case. BTW, it could be optimized more, by only setting the base bath to 32bit or 64bit, and use that in a single command after, which makes it really neat, and doesn't need an exit. The same can be done by checking %PROCESSOR_ARCHITECTURE%, as shown in the first comment.
Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
REG.exe Query %RegQry% | Find /i "x86" >nul && (
set base=32bit
) || (
set base=64bit
)
msiexec /i %base%\vpnclient_setup.msi LAUNCHSETMTU=0 /norestart /qn
Open in new window