Command line utility deletefile  
 

Navigation: Diese Seite in Deutsch - Main page - Contents


Download program or batch file Operating system Description
deletefile.exe

Version 1.00

Windows
(95/98/ME/
NT/2000/XP)
There is a problem with the internal DEL command of Windows, at least on Windows NT, service pack 6a. It seems to work fine on Windows 2000.
DEL does neither return a proper ERRORLEVEL nor does it care about stdout and stderr, hence you cannot ensure that a file really gets deleted.

Although a command like
DEL /Q file.test
normally works perfect, it is possible that the deletion does not take place at all.
Please note that the parameter /Q suppresses the overwrite question the DEL command might ask. There is no safe way to tell for sure that the file file.test was deleted.

The following sequences will not work properly on Windows NT:

DEL /Q file.test 2> delerrors.txt
IF ERRORLEVEL 1 ECHO Error.

DEL /Q \\server\file.test 2> delerrors.txt
IF ERRORLEVEL 1 ECHO Error.

If the command worked correctly, it would touch the file delerrors.txt (reduce its file size to 0) if file.test could be deleted successfully. On the other hand, delerrors.txt would contain the error message returned by DEL and the text "Error." would be written to the console (stdout), if there was an error while trying to delete the file. This works on Windows 2000, but not on Windows NT.

The command line utility deletefile.exe takes care of this. It is supposed to be a replacement for DEL /Q.
Use the following sequences instead:

DeleteFile file.test 2> delerrors.txt
IF ERRORLEVEL 1 ECHO Error.

DeleteFile \\server\file.test 2> delerrors.txt
IF ERRORLEVEL 1 ECHO Error.

Any other functionality must be provided by the user, i.e. a batch file.
For instance, if you require DIR's parameter /F (force deletion of read-only files), you need to implement this yourself like shown in the following sequence.

SET fName=file.test
ATTRIB -R %fName%
DeleteFile %fName% 2> delerrors.txt
IF ERRORLEVEL 1 ECHO Error.
 

Navigation: Diese Seite in Deutsch - Main page - Contents
 
 

---

All scripts (batch files) and programs provided by www.wabel.de.
Wagner Belmer GbR (WaBel)

(C) 2003 Thomas Belmer

ASAMnet - - PMView - Allee Parkhotel Maximilian - Autospenglerei Belmer - Email - Thomas's homepage - Bieruhr - Panoramas - Amberg live