+ Post New Thread
Results 1 to 9 of 9
How do you do....it? Thread, Delete local profiles. in Technical; Anyone got a script or a quick way of deleting all the local profiles that build up on a workstation ...
  1. #1

    Join Date
    May 2008
    Location
    Kent
    Posts
    94
    Thank Post
    57
    Thanked 10 Times in 10 Posts
    Rep Power
    14

    Delete local profiles.

    Anyone got a script or a quick way of deleting all the local profiles that build up on a workstation remotely or logged on as admin? VB or batch file would be great. Maybe adding it to "Admin Bar" project section!

    I did find something but it did not work
    TIA

  2. #2
    craigg's Avatar
    Join Date
    Feb 2008
    Location
    Birmingham, UK
    Posts
    175
    Thank Post
    15
    Thanked 9 Times in 6 Posts
    Rep Power
    15
    Try something like this:

    It might not be perfect so test it on your test machine before using it live. If anyone has any changes they think they could make post away!

    Code:
    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
    
    'Uncomment msgbox for notification
    'msgbox "Local Profiles Deleted","16","WARNING"
    Let me know how you get on anyway.

  3. 3 Thanks to craigg:

    brunanburh (9th December 2009), firefighting (15th July 2008), sven (27th April 2011)

  4. #3

    Join Date
    May 2008
    Location
    Kent
    Posts
    94
    Thank Post
    57
    Thanked 10 Times in 10 Posts
    Rep Power
    14
    Please ignore this post. Found all the necessary answer in a search on edugeeks. I did not look deep enough.
    ff

  5. #4

    TechMonkey's Avatar
    Join Date
    Dec 2005
    Location
    South East
    Posts
    3,293
    Thank Post
    226
    Thanked 406 Times in 303 Posts
    Rep Power
    162
    Delprof. Run it remotely and it works wonders.
    /Barry Scott
    BANG and the profiles are gone

  6. Thanks to TechMonkey from:

    firefighting (15th July 2008)

  7. #5

    Join Date
    May 2008
    Location
    Kent
    Posts
    94
    Thank Post
    57
    Thanked 10 Times in 10 Posts
    Rep Power
    14
    yep! this script worked very well. Thank you craigg. I found it more selective than delprof. Thanks once again
    ff

  8. #6

    Join Date
    Apr 2008
    Location
    Aigburth, Liverpool
    Posts
    156
    Thank Post
    35
    Thanked 10 Times in 10 Posts
    Rep Power
    15
    Don't think I've ever seen a script work so well! Many thanks!

  9. #7
    bio
    bio is offline
    bio's Avatar
    Join Date
    Apr 2008
    Location
    netherlands
    Posts
    520
    Thank Post
    16
    Thanked 130 Times in 102 Posts
    Rep Power
    38
    wrote an article on my blog a couple of months ago: Cleaning up student profiles on Windows XP machines « Knowledge for all (and free) !

    perhaps its usefull

    bio..

  10. #8

    Join Date
    Apr 2011
    Location
    Pennsylvania
    Posts
    48
    Thank Post
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    7
    +1 to delprof.

  11. #9


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,055
    Thank Post
    231
    Thanked 2,716 Times in 2,004 Posts
    Rep Power
    794
    Quote Originally Posted by craigg View Post
    If anyone has any changes they think they could make post away!
    Would it be possible to delete the user profiles listed in the registry to avoid Windows getting confused?

    How Do Users Get Their Profile?
    The way in which users get their profiles depends on the type of profile they're configured to use. This section describes this process.

    Roaming Profile - New User

    1. The user logs on.

    2. The path to the users roaming profile is retrieved from the user object on the Domain Controller.

    3. Windows checks to see if a profile exists in the roaming path, if no profile exists a folder is created.

    4. Windows checks the list of user profiles located in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList to determine if a cached copy of the profile exists. If a local copy of the profile is not found, and the computer is part of a domain, Windows checks to determine if a domain wide default profile exists in the Default User folder on the domain controllers NETLOGON share.

    5. If a domain wide profile exists, it is copied to a subfolder on the local computer with their user name under %Systemdrive%\Documents and Settings\.

    6. If a default domain profile does not exist, then the local default profile is copied from the %Systemdrive%\Documents and Settings\Default User folder to a subfolder on the local computer with their user name under %Systemdrive%\Documents and Settings\.

    7. The users registry hive (NTUSER.DAT) is mapped to the HKEY_CURRENT_USER portion of the registry.

    8. The users %userprofile% environment variable is updated with the value of the local profile folder

    9. The user can then run applications and edit documents as normal. When the user logs off, their local profile is copied to the path configured by the administrator. If a profile already exists on the server, the local profile is merged with the server copy (see merge algorithm later in this paper for more details).
    (Source)

SHARE:
+ Post New Thread

Similar Threads

  1. Script to Delete Profiles - PLEASE HELP
    By Mr_M_Cox in forum Scripts
    Replies: 13
    Last Post: 22nd February 2013, 03:53 PM
  2. delete certain profiles
    By chrbb in forum Scripts
    Replies: 4
    Last Post: 4th February 2010, 05:15 PM
  3. Local profiles
    By ozzy in forum How do you do....it?
    Replies: 3
    Last Post: 19th January 2008, 07:40 PM
  4. Delete printers from Profiles
    By Simcfc73 in forum Windows
    Replies: 3
    Last Post: 15th January 2008, 06:29 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •