Well, using VB6 it's really easy: if dir("c:\autoexec.bat", vbnormal) <> vbnullstring then kill "c:\autoexec.bat" . However, this becomes a little different in vbscript (and for some reason, a bit uglier).
Set filesys = WScript.CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("c:\somefile.txt") Then
In VBScript, Kill won't work. I don't think dir() works in VBScript either. If doing this in VB6 (compiled language) it is strongly recommended that you do NOT compare the result of dir with "". if dir("C:\MyText.txt") <> vbnullstring then is a much better method. Double quotes is what is known as a null string. It uses somewhere in the area of around 8 bytes. vbnullstring is a special constant that is built into VB6, that reduces the memory usage to like 1 byte. This isn't a very big deal for small apps with a couple of strings.... but when you get into recursion, or loops with string processing and checking, it will make a visible difference.