Solved

VBScript fso.deletefolder permission denied error on Vista

Posted on 2010-08-17
4
2,462 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

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.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

752 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