Link to home
Start Free TrialLog in
Avatar of hlmarine
hlmarine

asked on

VBS Scripting - Deleting Folder inside the current user profile

Hi,

I am looking for a script to delete a folder inside the current user AppData\Local\Microsoft\Outlook\test folder.

Here is the coding.

strPath = "%USERPROFILE%\AppData\Local\Microsoft\Outlook\Test"
WScript.Echo strPath
DeleteFolder strPath
Function DeleteFolder(strFolderPath)
Dim objFSO, objFolder
Set objFSO = CreateObject ("Scripting.FileSystemObject")
If objFSO.FolderExists(strFolderPath) Then
      objFSO.DeleteFolder strFolderPath, True
End If
Set objFSO = Nothing
End Function

However, the coding only detect the strPath as the exact wording of %USERPROFILE%\AppData\Local\Microsoft\Outlook\Test instead of C:\User\Username\AppData\Local\Microsoft\Outlook\Test.

Any expert can help ?

Thank you in advance !
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hlmarine
hlmarine

ASKER

Thanks ! Working ~