Jump to content

Recommended Posts

Posted

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

Posted

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!

 

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.

  • Thanks 3
  • 2 years later...
Posted
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? :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)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...