Solved

VBScript fso.deletefolder permission denied error on Vista

Posted on 2010-08-17
4
2,404 Views
Last Modified: 2012-05-10
Hi,

I want to add a function to delete the Outlook cache folder from my VBscript login script.

The additional code runs Ok but the folder is not deleted.

I took it out of the main body of the login script and tested separately and I get a permission denied error.

I have tested the script on another test folder on my desktop where I know I have permissions and it deletes the folder and displays the message.

Our PCs are Vista by the way...

Here is my script

dim WSHShell, fullpath, objFSO
set objFSO=CreateObject("Scripting.FileSystemObject")
Set WSHshell = CreateObject("WScript.Shell")
path="%userprofile%"
fullpath= WSHshell.ExpandEnvironmentStrings(path)
sCurrUsrPath = (fullpath & "\Appdata\Local\Microsoft\Windows\Temporary Internet Files\")

'Verify whether the Cache exists and delete it
If objFSO.FolderExists(sCurrUsrPath) Then
Const DeleteReadOnly = True
objFSO.DeleteFolder(sCurrUsrPath), DeleteReadOnly

msgbox "The Cache has been cleared successfully"

Else

msgbox "Cannot find the Cache. It may have been cleared already."

End If

Thanks in advance for any help!
Regards
0
Comment
Question by:Daza_WIlliams
  • 3
4 Comments
 
LVL 5

Expert Comment

by:xdomains
ID: 33453129
Launch your app with "Run as administrator". Or, disable UAC.
0
 

Accepted Solution

by:
Daza_WIlliams earned 0 total points
ID: 33453144
Hi,

Sorry, I have fixed the issue, strangely when I took out the / at the end of the path it worked.

eg: Orginal path
sCurrUsrPath = (fullpath & "\Appdata\Local\Microsoft\Windows\Temporary Internet Files\")

Updated path
sCurrUsrPath = (fullpath & "\Appdata\Local\Microsoft\Windows\Temporary Internet Files")

Thanks anyway!
0
 
LVL 5

Expert Comment

by:xdomains
ID: 33453150
It is possible that some files are in use. If you do have admin rights, then I guess some files are in use? UAC may not be the issue.
0
 
LVL 5

Expert Comment

by:xdomains
ID: 33453153
Ok, Good..:)
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question