PC Review


Reply
Thread Tools Rate Thread

conditional proccessing symbols question

 
 
djc
Guest
Posts: n/a
 
      21st Jun 2004
this is a copy/paste from the windows help file:

when it says 'only if the command preceding the symbol is successfull' or
'only if the command preceding the symbol fails' what exactly constitutes
'successfull'? Is it the same thing as errorlevel? any error level other
that 0 is failed? or would for example a copy command completing with an
error level still be considered successfull completion of the command?

could I use something like this:

xcopy c:\file1 d:\file2 && SET MyVar=Success
IF %MyVar%==Success (
ECHO success >> c:\log.txt
) ELSE (
ECHO failed >> c:\og.txt
)

any info is greatly appreciated. Thanks.



 
Reply With Quote
 
 
 
 
Paul R. Sadowski
Guest
Posts: n/a
 
      21st Jun 2004

"djc" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> xcopy c:\file1 d:\file2 && SET MyVar=Success
> IF %MyVar%==Success (


If the xcopy command failed then %MyVar% would not be defined and you'd get
a syntax error. So, this would work:
setlocal
xcopy c:\file1 d:\file2 && SET MyVar=Success
IF "%MyVar%"=="Success" (
ECHO success>> c:\log.txt
) ELSE (
ECHO failed>> c:\log.txt
)

Alternately:
setlocal
set MyVar=nothing
xcopy c:\file1 d:\file2 && SET MyVar=Success
IF %MyVar%==Success (
ECHO success
) ELSE (
ECHO failed
)

But more easily:
xcopy c:\file1 d:\file2
if ERRORLEVEL 1 (
echo failed>> c:\log.txt
) else (
echo success>> c:\log.txt
)
No need to set any variables.


 
Reply With Quote
 
djc
Guest
Posts: n/a
 
      21st Jun 2004
Thanks.

"Paul R. Sadowski" <(E-Mail Removed)> wrote in message
news:%23$(E-Mail Removed)...
>
> "djc" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > xcopy c:\file1 d:\file2 && SET MyVar=Success
> > IF %MyVar%==Success (

>
> If the xcopy command failed then %MyVar% would not be defined and you'd

get
> a syntax error. So, this would work:
> setlocal
> xcopy c:\file1 d:\file2 && SET MyVar=Success
> IF "%MyVar%"=="Success" (
> ECHO success>> c:\log.txt
> ) ELSE (
> ECHO failed>> c:\log.txt
> )
>
> Alternately:
> setlocal
> set MyVar=nothing
> xcopy c:\file1 d:\file2 && SET MyVar=Success
> IF %MyVar%==Success (
> ECHO success
> ) ELSE (
> ECHO failed
> )
>
> But more easily:
> xcopy c:\file1 d:\file2
> if ERRORLEVEL 1 (
> echo failed>> c:\log.txt
> ) else (
> echo success>> c:\log.txt
> )
> No need to set any variables.
>
>



 
Reply With Quote
 
djc
Guest
Posts: n/a
 
      21st Jun 2004
thank you.

"Tom Lavedas" <(E-Mail Removed)> wrote in message
news:EF8B0152-90F2-4B5F-AA27-(E-Mail Removed)...
> ERRORLEVEL > 0 is ALWAYS a failure in regard to &&. The idea is just to

allow for shorthand error branching/processing.
>
> Tom Lavedas
> ===========
>
>
> "djc" wrote:
>
> > this is a copy/paste from the windows help file:
> >
> > when it says 'only if the command preceding the symbol is successfull'

or
> > 'only if the command preceding the symbol fails' what exactly

constitutes
> > 'successfull'? Is it the same thing as errorlevel? any error level other
> > that 0 is failed? or would for example a copy command completing with an
> > error level still be considered successfull completion of the command?
> >
> > could I use something like this:
> >
> > xcopy c:\file1 d:\file2 && SET MyVar=Success
> > IF %MyVar%==Success (
> > ECHO success >> c:\log.txt
> > ) ELSE (
> > ECHO failed >> c:\og.txt
> > )
> >
> > any info is greatly appreciated. Thanks.
> >
> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
conditional compilation symbols Alcibiade Microsoft C# .NET 0 29th Dec 2010 04:27 PM
Conditional compilation symbols Goose14 Microsoft C# .NET 3 6th Aug 2007 11:36 PM
Word proccessing =?Utf-8?B?am9obmQ=?= Windows XP General 2 12th Oct 2006 03:39 PM
Conditional symbols NewGuy100 Microsoft Excel Programming 1 11th Oct 2005 03:15 PM
Loopback Proccessing Tony Cooke Microsoft Windows 2000 Group Policy 1 11th Feb 2004 02:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:58 PM.