'######################################################## '### Deletes a single file at the location supplied ### '### ### '### (c) Dirk Pelzer 2002 ### '######################################################## Option Explicit Dim iRet iRet = DeleteFile ("C:\DPC\Test.txt") wscript.echo "Error Code: " & iRet Function DeleteFile (strFileName) ' Returns 0 on success an 1 on error Dim fso Dim file Set fso = CreateObject("Scripting.FileSystemObject") err.clear on Error resume next Set file = fso.GetFile(strFileName) If fso.FileExists(strFileName) Then file.Delete Set file = nothing set fso = nothing If err.number <> 0 Then DeleteFile = 1 Else DeleteFile = 0 End if On error goto 0 End Function