Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: errormode(@off) errormode(@cancel)
User writes a script that deletes all the temp files from his temp directory at startup. Sometimes there are no files so errors were suppressed to avoid messages. Script read:
ErrorMode(@OFF) DirChange("C:\TEMP") FileDelete("*.*")and he put the script in his startup directory. Everything ran fine for months.
Then, being short of disk space on C:, moved the temp directory to D:\TEMP
Next time boot up occurred, the script was run. The DirChange failed but because error mode was @OFF, the script continued to run.
Needless to mention, the FileDelete("*.*") performed flawlessly. Too bad it was not pointing to any intended directory.
The function for which the errors are being suppressed should be isolated from other functions and operators as much as possible.
e.g. ; INCORRECT USAGE of ErrorMode( ) ; In this instance, when the copy has an error, the entire if ; statement is canceled. ; Execution begins (erroneously) at the next line, and states ; that the copy succeeded. Next a fatal error occurs as the ; "else" is found, since it does not have a matching if ErrorMode(@OFF) if FileCopy(file1,file2,@FALSE) == @TRUE Message("Info", "Copy worked") else Message("Error", "Copy failed") endif
Article ID: W12710
Filename: Two Minute Lecture on ErrorMode No-Nos.txt
File Created: 2010:02:17:11:58:34
Last Updated: 2003:03:19:08:28:48