By David Wiseman (Administrator)Created 14 Jan 2006
My Rating:
Vote
Rating:
Not Rated
Views:47605
Downloads:1802

Delete Local Profiles

Language:  VBScript

Description

Delete all the local profiles stored on a computer.(All folders stored in the "C:\Documents and Settings\" folder with a few exceptions added.)


Notes
This script could be run as a start-up or shutdown script to stop windows saving copies of user profiles. Please note that there is a group policy setting to delete cached copies of roaming profiles, and running this script might impact logon performance. Please use this script with particular caution as it has the potential to delete user documents if folder redirection is not used. 
Code

Line Numbers: On  Off      Plain Text
Const LocalDocumentsFolder = "C:\Documents and Settings\"

set objFSO = createobject("Scripting.FileSystemObject")
set objFolder = objFSO.GetFolder(localdocumentsfolder)

on error resume next

for each fldr in objFolder.SubFolders
	if not isexception(fldr.name) then
		objFSO.DeleteFolder fldr.path, True
	end if
next


Function isException(byval foldername)
	select case foldername
		case "All Users"
			isException = True
		case "Default User"
			isException = True
		case "LocalService"
			isException = True
		case "NetworkService"
			isException = True
		case "Administrator"
			isException = True
		case Else
			isException = False
	End Select
End Function

 


Got a useful script? Click here to upload!


 

  Post Comment
Order By:  
User Comments
      
topokin1
Posted On: 7/18/2008 6:45:43 AM

Would there be a way to extend the script to also check the age of the profile before deleting it. For example, that only profiles older than 1 month should be deleted.

tskrich
Posted On: 9/10/2008 12:36:18 PM

Although i do like scripts, There is a Microsoft utility that will let you to delete profiles. I use this on a regular basis.
http://www.microsoft.com/DownLoads/details.aspx?familyid=901A9B95-6063-4462-8150-360394E98E1E&displaylang=en

garish22
Posted On: 1/18/2013 12:36:51 AM

Can I use this script as it is or should change some lines? can you answer fast. I am really in need of this. Thank you, Regards, Gary

20171130caihuali
Posted On: 11/29/2017 11:44:11 PM

nhl jerseys ugg boots clearance fitflops reebok outlet store ray ban sunglasses ray ban sunglasses michael kors handbags nike foamposite mulberry handbags longchamp pliage coach outlet ferragamo outlet true religion outlet canada goose outlet canada goose jackets polo shirts ugg boots clearance michael kors outlet canada goose jackets polo ralph lauren ugg outlet canada goose jackets cheap snapbacks nike outlet ugg outlet canada goose coats michael kors michael kors outlet thomas sabo canada goose jackets pandora jewelry fitflops sale clearance mont blanc pens canada goose outlet reebok trainers michael kors outlet michael kors black friday moncler jackets christian louboutin online polo ralph lauren air max 90 fitflops shoes oakley sunglasses longchamp outlet polo ralph lauren moncler outlet ugg outlets ugg outlet ray ban sunglasses longchamp bags coach outlet oakley sunglasses ralph lauren polo adidas wings longchamp outlet ugg outlet canada goose jackets christian louboutin shoes coach outlet canada goose outlet uggs outlet nike air max 2015 michael kors outlet pandora jewelry lakers jerseys nike outlet lacoste soldes coach outlet online supra shoes pandora charms sale clearance nike roshe michael kors outlet cazal sunglasses coach outlet kobe bryant shoes new balance shoes ugg outlet nfl jersey wholesale ugg outlet michael kors outlet tory burch outlet air max 90 coach outlet online canada goose outlet coach outlet michael kors handbags prada outlet burberry outlet jordan shoes prada shoes coach factory outlet polo ralph lauren uggs outlet ferragamo outlet tods outlet nba jerseys air max 90 coach outlet ugg boots clearance coach handbags polo ralph lauren michael kors handbags true religion jeans michael kors outlet uggs outlet air max 1 ugg outlet michael kors outlet online coach outlet christian louboutin uk nike air force 1 michael kors outlet oakley sunglasses ray ban sunglasses coach outlet ugg outlet uggs outlet michael kors outlet true religion jeans mcm outlet ugg outlet adidas trainers swarovski crystal kate spade outlet oakley sunglasses ugg boots clearance ugg boots uggs ray ban sunglasses mbt shoes canada goose outlet true religion jeans ferragamo shoes michael kors handbags tory burch outlet tory burch outlet ray-ban sunglasses longchamp solde giuseppe zanotti outlet coach outlet online nike air max canada goose jackets converse shoes ferragamo shoes moncler jackets prada handbags longchamp solde polo ralph lauren nike shoes ugg boots jordan shoes canada goose jackets oakley sunglasses pandora charms sale clearance cheap jordans kate spade outlet oakley sunglasses ray ban sunglasses birkenstock sandals nike store oakley sunglasses soccer jerseys michael kors handbags toms sko coach outlet cheap nhl jerseys ecco shoes oakley sunglasses mulberry handbags polo outlet football shirts ugg cyber monday oakley sunglasses oakley sunglasses marc jacobs outlet vans outlet ed hardy clothing hermes outlet cheap jordans christian louboutin outlet true religion outlet coach outlet swarovski outlet ralph lauren outlet ugg boots clearance michael kors outlet true religion outlet ray ban sunglasses vans shoes longchamp handbags true religion outlet cheap jerseys michael kors outlet swarovski crystal coach handbags michael kors outlet online ray ban sunglasses canada goose jackets coach outlet online polo outlet true religion jeans hermes belt oakley sunglasses wholesale ugg boots coach outlet online bottega veneta outlet ugg boots clearance canada goose jackets prada sunglasses coach outlet longchamp handbags fitflops sale clearance michael kors outlet uggs outlet dansko shoes ray ban sunglasses ray ban sunglasses mulberry bags canada goose outlet links of london tory burch shoes michael kors outlet coach outlet mulberry bags jordan shoes nike store uk ray ban sunglasses michael kors oakley sunglasses christian louboutin outlet ysl outlet burberry outlet michael kors outlet coach outlet canada ugg boots kate spade outlet soccer jerseys ferragamo outlet herve leger outlet ugg outlet cheap nfl jerseys oakley sunglasses oakley sunglasses polo ralph lauren coach outlet ugg outlet michael kors outlet hermes outlet futbol baratas ugg outlet nike outlet ferragamo outlet pandora jewelry ugg outlet converse shoes air max trainers ray ban sunglasses soccer shoes ugg boots chrome hearts cheap jerseys uggs outlet ugg boots adidas sko new balance shoes michael kors outlet online michael kors uk moncler outlet ugg boots clearance swarovski outlet tory burch outlet michael kors outlet canada goose outlet canada goose outlet canada goose outlet air max uk coach factory outlet coach outlet store online oakley sunglasses yeezy boost kevin durant shoes jordan shoes oakley sunglasses coach outlet online ugg outlet polo outlet true religion jeans moncler outlet ralph lauren polo nfl jerseys wholesale mac cosmetics swarovski outlet uggs outlet canada goose black friday tory burch outlet ralph lauren uk yeezy boost 350 ray ban sunglasses christian louboutin shoes longchamp pas cher ugg outlet michael kors factory outlet canada goose parka nike shoes air huarache ugg black friday coach outlet michael kors outlet online swarovski outlet canada goose outlet mulberry outlet adidas uk michael kors outlet online ugg boots canada goose outlet true religion uk michael kors bags coach outlet online salomon shoes canada goose outlet ecco sale canada goose cyber monday michael kors outlet cleveland cavaliers jersey nike free 5 ugg outlet coach factory outlet coach outlet pandora charms uggs outlet canada goose outlet oakley sunglasses canada goose outlet ralph lauren polo true religion jeans michael kors outlet cartier outlet christian louboutin shoes coach outlet online ray ban sunglasses adidas nmd canada goose outlet canada goose jackets burberry outlet montblanc pens adidas outlet store ugg outlet air huarache coach canada ralph lauren uk tory burch outlet ralph lauren outlet true religion jeans fitflops outlet kobe 9 christian louboutin shoes ugg outlet mont blanc pens ralph lauren polo shirts adidas nmd polo ralph lauren kobe shoes lebron james shoes cheap snapbacks ray ban sunglasses puma outlet cheap mlb jerseys ugg outlet ray ban sunglasses puma shoes kate spade outlet oakley sunglasses polo ralph lauren adidas shoes nike air max 90 kate spade outlet ralph lauren polo canada goose outlet true religion jeans fitflops shoes michael kors basketball shoes fitflops coach factory outlet michael kors outlet ralph lauren outlet ugg outlet coach outlet nike trainers coach factory outlet ugg outlet coach outlet online uggs outlet nike trainers polo outlet mulberry handbags ralph lauren pas cher coach outlet oakley sunglasses christian louboutin outlet mulberry handbags canada goose jackets kate spade outlet polo outlet ugg outlet ugg boots clearance michael kors wallets michael kors outlet hermes birkin canada goose outlet timberland boots kicks nice michael kors outlet pandora jewelry mulberry outlet valentino outlet coach factory outlet oakley sunglasses wholesale ray ban sunglasses burberry outlet birkenstock outlet nike factory outlet christian louboutin outlet coach outlet longchamp outlet polo ralph lauren polo ralph lauren cheap mlb jerseys cheap jordans louboutin shoes ugg outlet tory burch outlet nike roshe one nba jerseys canada goose outlet ralph lauren polo shirts canada goose outlet mulberry sale chicago blackhawks jerseys christian louboutin outlet coach outlet oakley sunglasses longchamp handbags oakley sunglasses air max 90 uggs outlet asics shoes fitflops sale clearance lacoste polo shirts canada goose outlet polo ralph lauren canada goose outlet michael kors outlet ugg outlet true religion jeans uggs outlet christian louboutin outlet true religion jeans air jordan 4 michael kors Girls shoes cheap jordans ugg outlet oakley sunglasses chrome hearts outlet polo ralph lauren huaraches shopping ray bans fitflops sale michael kors handbags ugg boots nike trainers coach outlet longchamp handbags canada goose jackets ugg outlet christian louboutin outlet fred perry polo shirts michael kors handbags moncler outlet christian louboutin shoes coach outlet online nike outlet true religion jeans ferragamo outlet nike blazer pas cher 20171130caihuali