A
Aaron
is this possible in cmd without writing a batch file?
ie
c:/>cd windows;cd system32
c:/windows/system32>
Aaron
ie
c:/>cd windows;cd system32
c:/windows/system32>
Aaron
Hi,Aaron said:is this possible in cmd without writing a batch file?
ie
c:/>cd windows;cd system32
c:/windows/system32>
Torgeir Bakken (MVP) said:&& means "Do the command after && if the command before && succeeded".
I've seen this a number of times but can not figure what exactly determines
if the command before succeeded. I'm guessing an errorlevel of zero.
However, some programs return non-zero values for success too.
So what is the criteria for && to mean a program succeeded?
William Allen said:I've seen this a number of times but can not figure what exactly determines
if the command before succeeded. I'm guessing an errorlevel of zero.
However, some programs return non-zero values for success too.
So what is the criteria for && to mean a program succeeded?
did not complete successfully=receives an error code greater than zero
Quoted from:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-
us/ntcmds_o.mspx
under sub-item Concepts, sub-sub-item Command Shell Overview
===Quote starts
&& [...]
command1 && command2
Use to run the command following && only if the
command preceding the symbol is successful. Cmd.exe
runs the first command, and then runs the second command
only if the first command completed successfully.
|| [...]
command1 || command2
Use to run the command following || only if the command
preceding || fails. Cmd.exe runs the first command, and
then runs the second command only if the first command did
not complete successfully (receives an error code greater
than zero).
===End quote
============Screen capture Windows 2000 simulated in Win95
C:\WORK>echo n|choice || echo counts as failed
[Y,N]?N
counts as failed
C:\WORK>echo n|choice && echo counts as failed
[Y,N]?N
C:\WORK>
============End screen capture #1
Why is displaying ECHO's help considered a failure but REM's is not? Also,
since I can set errorlevel to any value before the test and it will be
unchanged afterwards, it seems the errorlevel state is bypassed/ignored.
ISTM, Microsoft's explanation for && and || operation does not hold water.
The result above is inconsistent with the documentation.
Why is displaying ECHO's help considered a failure but REM's is not? Also,
since I can set errorlevel to any value before the test and it will be
unchanged afterwards, it seems the errorlevel state is bypassed/ignored.
ISTM, Microsoft's explanation for && and || operation does not hold water.
The result above is inconsistent with the documentation.
William Allen said:(replaces earlier cancelled message)
in message
...snip
Useful points. So noted.
Treating:
ECHO /? || ECHO this will be displayed
ECHO /? && ECHO this will not be displayed
as the "rule" for /? help commands, are you aware of any other /?
exceptions apart from the REM command?
And are you aware of any other apparent inconsistencies in && and ||
handling apart from the /? treatment?
Motto for documentation fans:
"The only accurate program documentation is what the program does."