Gmail Kalender Dokumenter Nettet Læser mere »
Senest besøgte grupper | Help | Sign in
Google Grupper startside
"set errorlevel=something..." could be dangerous
Der er for øjeblikket for mange emner i denne gruppe, som skal vises øverst. For at vise dette emne først skal du fjerne denne mulighed fra et andet emne.
Der opstod en fejl under behandling af din anmodning. Prøv igen.
marker
  2 indlæg - Skjul alle  -  Oversæt alt til Oversat (Vis alle oprindelige)
Gruppen, du sender indlæg til, er en Usenet-gruppe. Indlæg til denne gruppe vil gøre din e-mail-adresse synlig for alle på internettet.
Dit svar er ikke blevet sendt.
Dit indlæg er blevet sendt
 
Fra:
Til:
Cc:
Opfølgning til:
Tilføj cc | Tilføj opfølgning til | Rediger emne
Emne:
Validering:
Indtast de tegn, du ser på billedet nedenfor, eller de numre, du hører, ved at klikke på adgangsikonet for at bekræfte. Lyt og indtast de tal, du hører
 
b.peder...@get2net.dk  
Se profil   Oversæt til Oversat (vis oprindelig)
 Flere valgmuligheder 1 Jan. 2007, 10:31
Nyhedsgrupper: alt.msdos.batch.nt
Fra: b.peder...@get2net.dk
Dato: 1 Jan 2007 01:31:37 -0800
Lokalt: Ma. 1 Jan. 2007 10:31
Emne: "set errorlevel=something..." could be dangerous
@echo off& setlocal enableextensions enabledelayedexpansion
(set raw=.CR2)& rem Canon EOS 30D
goto:_Database
...SNIP

Since it's 01/01/2007, I would first say "happy new year", then say
that I don't read my e-mails...

The syntax "set errorlevel=something..." could be dangerous when
it's used/mixed with some of the older syntax such as
"if errorlevel something..."

I knew that a syntax such as COLOR 07 would set the errorlevel to 0
and that COLOR 11 would set the errorlevel to 1, but when I found the
solution (set errorlevel=), then I forgot to evaluate previous syntax,
so if you already had (set errorlevel=) somewhere in a batch file,
and then later repeat that reset, the last one would set the error
level to 1, ofcause. In other words: it should be followed by a
color 07, or set another variable to something except nothing, ex:
(set errorlevel=)&(set variable=X)

So the solution for CMD files is simply this:
set errorlevel=& color 07& rem -- reset, AND set both errorlevels to 0.

Benny Pedersen,
PS. Havn't the point, so
Try the following with an extension CMD, (BAT extension would fail)...

@echo off
(SET A=)
  if errorlevel 1 if not errorlevel 2 echo  ER is 1,
  echo %%ER%% = %errorlevel%, so errorlevel is 1.& echo.

color 07& rem -- bgcolor and errorlevel is now set to 0.
  if not errorlevel 1 echo  ER is 0,
  echo %%ER%% = %errorlevel%, so errorlevel is 0.& echo.

(SET A=)
  if errorlevel 1 if not errorlevel 2 echo  ER is 1,
  echo %%ER%% = %errorlevel%, so errorlevel is 1.& echo.

(set errorlevel=0)
  if not errorlevel 1 echo  ER is 0,
  echo %%ER%% = %errorlevel%, so errorlevel is 0.& echo.

color 11& rem -- errorlevel is now set to 1.
  if not errorlevel 1 echo  ER is 0.
  if errorlevel 1 echo  ER is 1...
  echo %%ER%% = %errorlevel%, BUT errorlevel is 1.& echo.

(set errorlevel=)& rem OOPS.
set errorlevel=& color 07& rem Reset, AND set both errorlevels to 0.
pause
goto:eof

Btw. I'm working on a new batch file to handle the XMP files for
Adobe Photoshop and PSE, and it work very fine.
Security and stability - No data should be deleted. Fact is that
a child should be able to use it, and even if my cat was walking
on my keyboard, this my new batch file should not fail...
So why use the ugly Abobe Database when shooting RAW files...
I will later upload my new CMD file to this forum:
http://www.photoshopelementsuser.com/forum/showthread.php?t=17609

:XMP
  echo.  Create XMP Sidecar, from
  echo.
  echo.     0: Default  ^(Empty XMP files^)
  echo.     1: Internal Template
  echo.     2: External Template
  echo.     3: Previous
  echo.
  echo.     4: Cleanup ^(Delete XMP files that's not used^)
:_0
  for %%R in ("%~dp1*%raw%") do (
    echo Creating "%%~dpnR.XMP"
    type nul    > "%%~dpnR.XMP"
  )
...SNIP...


    Videresend  
Log ind, før du kan sende indlæg.
For at sende et indlæg skal du først tilmelde dig gruppen.
Opdater dit kaldenavn på siden Abonnementsindstillinger, før du sender.
Du har ikke den krævede tilladelse til at sende.
Alan Adams  
Se profil   Oversæt til Oversat (vis oprindelig)
 Flere valgmuligheder 7 Jan. 2007, 03:56
Nyhedsgrupper: alt.msdos.batch.nt
Fra: Alan Adams <alanad...@nospam.nospam>
Dato: Sun, 07 Jan 2007 02:56:59 GMT
Lokalt: Sø. 7 Jan. 2007 03:56
Emne: Re: "set errorlevel=something..." could be dangerous

b.peder...@get2net.dk wrote:
> The syntax "set errorlevel=something..." could be dangerous when
> it's used/mixed with some of the older syntax such as
> "if errorlevel something..."

I'm missing the context in which it was recommended that "set
errorlevel=x" was actually a solution to something, or in any way a
good idea.  The SET /? documentation says as much.

("If the user explicitly defines a variable with one of these names,
then that definition will override the dynamic one described below:")

So while its agreed that "set errorlevel=" would undo the problem
created by someone using "set errorlevel=0" or similar, in general any
form of "set errorlevel" is not a good idea and does not yield the
generally expected or useful result.

(Note Microsoft's own Windows Driver Kit SETENV.BAT exemplifies this
same issue, by trying to use "set errorlevel=0" to ensure errorlevel
isn't raised on exit.  Does not work, of course, and just blows up all
the "if %errorlevel%" tests that happen after calling SETENV.BAT.)

Alan Adams


    Videresend  
Log ind, før du kan sende indlæg.
For at sende et indlæg skal du først tilmelde dig gruppen.
Opdater dit kaldenavn på siden Abonnementsindstillinger, før du sender.
Du har ikke den krævede tilladelse til at sende.
Ikke flere indlæg
« Tilbage til diskussioner « Nyere emne     Ældre emne »

Opret en gruppe Google Grupper - Google startside - Servicevilkår - Politik til beskyttelse af personlige oplysninger
©2010 Google