I acquired code from this site to delete a file:
Working with an application called HEAT, that can run automated programs. One of these programs produces a temp file each time it is run. I'd like to clean out the temp files for users by adding a script to the beginning of the program so that all temp files will be deleted prior to the program running.
The temp file names are "HFW9999" where 9999 can be any numbers. The files always start with HFW and they have no extension. So in my example above, this script will delete any file named HFW1...
How can I get it to include all files with any number after the HFW? To add a twist, it can only be numbers, not letters, as there are actually valuable .DLLs that also begin with "HFW" followed by letters.
Also, this script bombs out if the file does not exist...is there a way I can add a "if exists" kind thing so that it will delete the file(s) if they are there, but will not error out if they're not?
Thanks...hope this is not too confusing...
stinsman
Code:
Set fso = Wscript.CreateObject("Scripting.FilesystemObject")
fso.DeleteFile "C:\Program Files\HEAT\HFW1*",True
Working with an application called HEAT, that can run automated programs. One of these programs produces a temp file each time it is run. I'd like to clean out the temp files for users by adding a script to the beginning of the program so that all temp files will be deleted prior to the program running.
The temp file names are "HFW9999" where 9999 can be any numbers. The files always start with HFW and they have no extension. So in my example above, this script will delete any file named HFW1...
How can I get it to include all files with any number after the HFW? To add a twist, it can only be numbers, not letters, as there are actually valuable .DLLs that also begin with "HFW" followed by letters.
Also, this script bombs out if the file does not exist...is there a way I can add a "if exists" kind thing so that it will delete the file(s) if they are there, but will not error out if they're not?
Thanks...hope this is not too confusing...
stinsman