Micro Focus QTP (UFT) Forums

Full Version: script for deleting cookies
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Recently i face this question in an interview, write a script to delete cookies..

help me to know the script..

thanks for every help
Hi,
Try the below code.

Code:
Function ClearCookies()
    On Error Resume Next
    Const TEMPORARY_INTERNET_FILES = "&H20&"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(TEMPORARY_INTERNET_FILES)
    objFSO.DeleteFile(objFolder.Self.Path & "\*.*")

    sPath = objFSO.GetFolder(objFolder.Self.path) & "\Content.IE5\"
    Set objFolders = objFSO.GetFolder(sPath)
    For Each objFName In objFolders.SubFolders
        WScript.Echo sPath & objFName.Name
        objFSO.DeleteFolder(sPath & objFName.Name)
    Next
    If Err.Number <> 0 Then
       err.Clear
       ClearCookies = 0
     Else
       ClearCookies = 1
      End If    
End Function

Regards,
Ankesh
webutil.deletecookies
Thank you Ankesh



Thank you Ravi



Thank you, Inborntester, thanks for awareing me to search for my question insted posting a thread, from the next time onwards, before i post a question, i will search in the site...

Thank you every one
Code:
webutil.deletecookies
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351"