zammalabe
maybe i have missed something, but can somebody tell me is there any errorlevel (or similar implementation) for del command in winxp? i assumed, that errorlevel==0 when the command succeeded and when errorlevel==1 the command failed? thats seems to work with copy command, but wit del command :pc: ... huhh sad
yeah, i know the piping errors
2>
, but to use that in simple batch file for task such "when deletion files, do something", is little bit ....
----------------------------
#2 22 Jan 2009 05:15
carlos
The errorlevel 0 is succes.
The errorlevel different of 0 is fail. (-1,1,2,3,4,9009,etc)
Example:
Code: Select all
program [args] && (echo.Success) || (echo.Fail)
Example:
Code: Select all
program [args]
if errorlevel 1 (
echo.Fail
) else (
if errorlevel 0 (echo.Success) else (
echo.Fail
)
)
But as del seems like the always returns 0. I could do:
Code: Select all
del /f /q /a "file.txt" >nul 2>&1
if exist "file.txt" (echo.Fail) else (
echo.Success
)
Code: Select all
del /f /q /a "file.txt" >nul 2>&1
dir /a "file.txt" >nul 2>&1 && (echo.Fail) || (echo.Success)
Last edited by carlos (22 Jan 2009 05:41)
----------------------------
#3 22 Jan 2009 13:50
bluesxman
How about this?
Code: Select all
del /f /q/ a "file.txt" 2>&1 | findstr "." > nul
if errorlevel 1 (echo:Success) ELSE (echo:Fail)
Last edited by bluesxman (22 Jan 2009 13:50)
cmd | *sh | ruby | chef