Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: 1016 filedelete
I have the following code in a winbatch script:
If FileExist("spslocks.dat") == @FALSE Then goto upload FileDelete("spslocks.dat") FileWrite(logHandle, strCat(TimeDate(), " spslocks.dat deleted.")) :upload Run("wupload.exe", "immediate USERLIST(UPLIST.DAT) OLDDBD")Usually the code works, but sometimes I get 1016: FileDelete file not found FileDelete["spslocks.dat"].
The file exists, but it might have been in use when the FileDelete that failed was issued. Is it possible that file in use or some permission failure is causing the file not found error?
FileExist will search the path for the file. FileDelete will not. Is the file marked read-only, or does it belong to a running EXE file, or is it open by a running application? Will DOS DelTree delete this file?
Can you write a one line script to delete the file that it fails on?
If FileExist returns a 2, meaning that it is opened in read deny mode by another application, it is unlikely a delete operation would be successful.
There seem to be at least two possibilities in your situation:
curdir=DirGet() If FileExist("%curdir%spslocks.dat") == @FALSE Then goto upload If FileExist("%curdir%spslocks.dat") == 1 FileDelete("spslocks.dat") FileWrite(logHandle, strCat(TimeDate(), " spslocks.dat deleted.")) else FileWrite(logHandle, strCat(TimeDate(), " spslocks.dat file in use !!!!.")) endif :upload Run("wupload.exe", "immediate USERLIST(UPLIST.DAT) OLDDBD")
If FileExist("c:\ifprot.exe") FileDelete("c:\ifprot.exe") EndIfDebug shows:
If FileExist("c:\ifprot.exe") IF DO ==> TRUEThe FileDelete statement is the very last command in the program IFPROT.EXE, which is the file I'm trying to delete. I'm trying to clean up by deleting the program after it ends. Maybe this is the problem. If so, how would you remove a program from the hard drive after it completes execution?
What I want is to have the program delete itself from the hard drive after execution is complete.
fn="c:\xxx.exe" if WinMetrics(-4)==4 ;NT IntControl(30,fn,"",0,0) endif if WinMetrics(-2)==5 ;95 wininitfile=strcat(DirWindows(0),"wininit.ini") if FileExist(wininitfile) ff=FileOpen(wininitfile,"APPEND") FileWrite(ff,strcat("NUL=",fn)) FileClose else ff=FileOpen(wininitfile,"WRITE") FileWrite(ff,"[rename]") FileWrite(ff,strcat("NUL=",fn)) FileClose endif endifFor 32 bit system this will delete the fn file at next reboot.
You *might* try ShellExecute-ing something else, (eg COMMAND.COM /c), to delete the EXE. Not sure whether or not this will work.
I am attempting to delete a shortcut on the desktop. I am getting the 1016 file not found. However FileExist is returning 1(meaning the file does exist) and the if condition is executed, but I am still getting the error 1016 "FILE NOT FOUND"! Why would that be????
fx= FileExist("c:\windows\profiles\desktop\allusers\desktop\update.lnk") If fx==1 FileDelete("c:\windows\profiles\desktop\allusers\desktop\update.lnk") EndIf
FileAttrSet ("c:\windows\profiles\desktop\allusers\desktop\update.lnk", "r");turns read-only off fx= FileExist("c:\windows\profiles\desktop\allusers\desktop\update.lnk") If fx==1 FileDelete("c:\windows\profiles\desktop\allusers\desktop\update.lnk") EndIf
Article ID: W12934
Filename: 1016 FileDelete File Not Found.txt
File Created: 1999:04:15:16:50:38
Last Updated: 1999:04:15:16:50:38