Deleting User Folder
Deleting User Folder
Deleting User Folder
Deleting User Folder
Deleting User Folder
Deleting User Folder Deleting User Folder Deleting User Folder Deleting User Folder Deleting User Folder Deleting User Folder Deleting User Folder Deleting User Folder
Deleting User Folder Deleting User Folder
Deleting User Folder
Go Back  Xtreme Visual Basic Talk > > > Deleting User Folder


Reply
 
Thread Tools Display Modes
  #1  
Old 10-09-2014, 03:09 PM
ancameron ancameron is offline
Newcomer
 
Join Date: Oct 2014
Posts: 2
Default Deleting User Folder


I am making a program for our school district that will remove old student profiles from a Windows 7 machine. When I try to delete the folder, it says that access is denied. I am a local administrator and run the program as administrator as well. I have tried multiple ways and nothing will allow me to delete the folder. Is there another way to delete the folder that I am missing?

I have tried:

For Each findfolder As DirectoryInfo In directory.GetDirectories()
findfolder.Delete()
End Try

IO.Directory.Delete(user_folder)

My.Computer.FileSystem.DeleteDirectory(user_folder, Nothing)

I have tried changing the folder permissions and that also threw an error.
Is it just not possible?
Reply With Quote
  #2  
Old 10-09-2014, 03:18 PM
PlausiblyDamp's Avatar
PlausiblyDampDeleting User Folder PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

How are you changing the permissions? IIRC you would need to take ownership of the folders before deleting rather than just resetting permissions as you may not have the permissions to change permissions until you take ownership.

Rather than needing a VB app you could probably get away with the two command line utilities Takeown.exe and cacls.exe to do this.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 10-10-2014, 09:17 AM
ancameron ancameron is offline
Newcomer
 
Join Date: Oct 2014
Posts: 2
Thumbs up Solved!

Thank you! Thank you! I ran that takeown.exe as a process with admin rights and that allow me to take ownership of the folder and then delete it.
Reply With Quote
Reply

Tags
access denied, delete folder, user profile, windows 7


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Deleting User Folder
Deleting User Folder
Deleting User Folder Deleting User Folder
Deleting User Folder
Deleting User Folder
Deleting User Folder Deleting User Folder Deleting User Folder Deleting User Folder Deleting User Folder Deleting User Folder Deleting User Folder
Deleting User Folder
Deleting User Folder
 
Deleting User Folder
Deleting User Folder
 
-->