none
How delete folder in user profile RRS feed

  • Question

  • Hello,

    can someone help me with my vbs script ? ... something with path is wrong, my vbs skills are very low

    Set objFileSys = CreateObject("Scripting.FileSystemObject")
    strName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )
    Set objFolder = objFileSys.GetFolder("C:\Users\" + strName + "\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook")

    For Each Folder In objFolder.SubFolders
    FolderCreated = Folder.DateCreated
    FolderAge = DateDiff("d", FolderCreated, Now)

    If FolderAge >0 Then
    Folder.Delete
    End If

    Next

    Thank you very much

    • Moved by Bill_Stewart Tuesday, December 11, 2018 9:00 PM Unanswerable drive-by question
    Tuesday, July 17, 2018 10:50 AM

All replies

  • What is your error?

    If you do not know VBScript you should not be using it. Use PowerShell. VBScript is obsolete.


    \_(ツ)_/

    Tuesday, July 17, 2018 11:00 AM
  • This is the same code in PowerShell:

    $path = "$env:localappdata\Microsoft\Windows\INetCache\Content.Outlook\"
    Get-ChildItem $Path | Remove-Item -WhatIf


    \_(ツ)_/

    Tuesday, July 17, 2018 11:11 AM