[wpkg-users] [OT?] Nested for on a cmd script...

Stefan Pendl stefan.pendl.71 at gmail.com
Wed Feb 4 17:50:09 CET 2015


Am 04.02.2015 um 12:06 schrieb Marco Gaiarin:
> Mandi! Rainer Meier
>    In chel di` si favelave...
>
>>> but %type% (or !type!) is everytime 'REG_EXPAND_SZ', eg seems that
>>> 'find' call does not work, but instead work on commandline...
>> I didn't try but maybe you have to delay-expand !ERRORLEVEL! rathr
>> than %ERRORLEVEL% because the value needs to be delay-expanded or it
>> will be the same value on each loop.
> I've tried !ERRORLEVEL! and also the form:
>
> 	set type=REG_EXPAND_SZ
>          echo !pathrule! | find "%"
>          if ERRORLEVEL 1 (
>          	set type=REG_SZ
>          )
>
> reversing the logic, but both set 'type' to 'REG_SZ'. So:
>
>   a) 'if %ERRORLEVEL% equ 0' return everytime TRUE
>
>   b) 'if !ERRORLEVEL! equ 0' return everytime FALSE
>
>   c) 'if ERRORLEVEL 1' return everytime TRUE
>
> boh.
>
>
> I've fixed the value to 'REG_EXPAND_SZ'. ;(
>

How about the following?

Everything after && is only executed if the error-level is 0.
The opposite would be ||.

May be you need to escape the % sign by using %%, \% or ^%.

Remember that the command line is not working the same way as the batch 
file, many times variable expansion is done in the batch file but not on 
the command line.

'---code start (watch for line wraps)

set type=REG_SZ
echo !pathrule! | find "%" && set type=REG_EXPAND_SZ

'---code end

--
Stefan P.

Top-posting:
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?




More information about the wpkg-users mailing list