1.

Solve : Little help with small script?

Answer»

Okay, I need a little help figuring out why this isn't working. The probem is no matter what the VAR outlook always gets set to 2003. The PC i'm testing on has only office 2K installed. I have confirmed that the errorlevel is retruned correctly (errorlevel=1) so I can only presume that the problem lies in the else statement. I dunno it looks right to me. Any ideas?

Code: [Select]for /f "delims=" %%a in ('reg query hklm\software\microsoft\office /s ^| find /i "common\installroot"') do call :process "%%a"
GOTO :EOF

:process
echo %~1 | find /i "11" > nul
if errorlevel == 0 (
set outlook=2003
) else (
set outlook=2000
)
for /f "delims=" %%b in ('reg query %~1') do set opath=%%b
set opath=%opath:~22%
set opath=%opath:~0,-1%

:EOF
I should ADD for those that may not know: Office 2003 is version 11 and all the registry settings are nested in a subkey of "office" called 11.0. Same for the other version (e.g. office 2k is 9.0)I don't know about the rest, but that's not how you do errorlevel.

It's:

If errorlevel N command


N = 0 - 255 in descending order ie if you expect to choose between errorlevels 5 6 and 7 you have to do this

if errorlevel 7 goto eggs
if errorlevel 6 goto bacon
if errorlevel 5 goto toast

Alternative strategy:


set outlook=2000 & echo %~1 | find /i "11"> nul && set outlook=2003








Removing the == did not work...but I don't care, the second method did.

Thanks for the suggestionsee edit. I don't think errorlevel statements can be extended with parentheses. one line and goto label seems to be the preferred method.



Discussion

No Comment Found