Deleting files in special folders
I was trying today to write some VBScript in QTP to remove all the files from the Temporary Internet Files folder on Windows XP.
There is a simple QTP command WebUtil.DeleteCookies for deleting cookies, which works for IE if there are no browser windows open. But there no equivalent command for deleting the temporary Internet files.
I found several examples online that use the DeleteFile command. One that actually works is listed here:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov04/hey1102.mspx
The important part of this code is the second line:
Set objShell = CreateObject("Shell.Application")
This line has to be used because the Temporary Internet Files folder is a "special" folder does not behave like a normal folder. The normal method of deleting a folder will not work if the path to the folder is simply passed as a string.