Solved

VBScript fso.deletefolder permission denied error on Vista

Posted on 2010-08-17
4
2,361 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
Comment Utility
Launch your app with "Run as administrator". Or, disable UAC.
0
 

Accepted Solution

by:
Daza_WIlliams earned 0 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Ok, Good..:)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
wordappend challenge 8 84
Event ID: 1202 / Source: SceCli 6 43
C# code editing and collaboration 3 39
Path to Python 9 37
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
I'm a big fan of Windows' offline folder caching and have used it on my laptops for over a decade.  One thing I don't like about it, however, is how difficult Microsoft has made it for the cache to be moved out of the Windows folder.  Here's how to …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now