Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBScript fso.deletefolder permission denied error on Vista

Posted on 2010-08-17
4
Medium Priority
?
2,549 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Simple Linear Regression

877 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