Jump to content

Recommended Posts

Posted

hi all, i really need a script or .bat file or something that can delete the contense of the Documents and settings folder (ie all the user profiles) on the clients machines . i would lik eto be able to do it from the server without having to go to each machines and manually select them and delete tham. if any clarification is needed let me know because i am not great at explaining my issues.

cheers

Posted

You can use delprof.exe from Microsoft to remove profiles, we have it configured via group policy to run at machine startup.

Just a batch file with delprof /Q /D:1 in it.

 

Hope that helps.

Posted

cheers guys for the responses. Tango, that script did not work it entered delprof /Q /D:PC018

delprof /Q /D:PC019

 

but it didnt work, if this is wrong please correct me. oh and i need it to run without me having to confirm everything it is deleting

Posted

I use the script below, you can edit it to keep certain folders such as we have 'default user' administrator and all users' The chice is yours.

 

It has worked very well for us.

 

 

 

Function Main()

On Error Resume Next

Dim obtainfolder

Dim PathFolder

Dim strPath

 

 

Set fso = CreateObject("Scripting.FileSystemObject")

 

strPath = "C:\Documents and Settings\"

 

Set f = fso.GetFolder(strPath)

 

' Loop through all subfolders

For Each fldrItem in f.SubFolders

 

fldrName = fldrItem.name

 

If Right(strPath,1) <> "\" Then

PathFolder = strPath & "\" & fldrName

Else

PathFolder = strPath & fldrName

End If

 

Select Case fldrName

Case "Administrator":

Case "All Users":

Case "Default User":

Case Else:

 

set obtainfolder = fso.GetFolder(PathFolder)

obtainfolder.Delete true

End Select

 

Next

 

' Clean up objects

Set fso = Nothing

Set fc = Nothing

 

End Function

 

call Main()

  • Thanks 1
Posted

I use the script below, you can edit it to keep certain folders such as we have 'default user' administrator and all users' The chice is yours.

 

It has worked very well for us.

 

 

 

Function Main()

On Error Resume Next

Dim obtainfolder

Dim PathFolder

Dim strPath

 

 

Set fso = CreateObject("Scripting.FileSystemObject")

 

strPath = "C:\Documents and Settings\"

 

Set f = fso.GetFolder(strPath)

 

' Loop through all subfolders

For Each fldrItem in f.SubFolders

 

fldrName = fldrItem.name

 

If Right(strPath,1) <> "\" Then

PathFolder = strPath & "\" & fldrName

Else

PathFolder = strPath & fldrName

End If

 

Select Case fldrName

Case "Administrator":

Case "All Users":

Case "Default User":

Case Else:

 

set obtainfolder = fso.GetFolder(PathFolder)

obtainfolder.Delete true

End Select

 

Next

 

' Clean up objects

Set fso = Nothing

Set fc = Nothing

 

End Function

 

call Main()

Posted

Sorry , was typing that off the top of my head , just checked the batch file were have for machine start up and its :-

 

%windir%\delprof /q /i /d:0

 

Obviously we have delprof.exe copied to the windows dir on each PC.

 

We also run it manually on each PC when doing a general tidy up in case the PC hasnt been rebooted for a while. I work in a Uni so there can be perhaps 20 students logging on to a PC each day so they can build up over a few days if the PC hasnt been rebooted.

 

I have scripts to WOL all the PCs and then using psshutdown from Sysinternals pstools reboot them all , and I try to do this every so often early in the morning when nobody is logged on.

Posted

Does anyone factor in orphans i.e. D&S folders that aren't listed in the registry and in principle won't be touched by delprof?

 

[Don't ask me how that happens, but I've definitely seen them around]

  • 5 years later...
Posted
hi all, i really need a script or .bat file or something that can delete the contense of the Documents and settings folder (ie all the user profiles) on the clients machines . i would lik eto be able to do it from the server without having to go to each machines and manually select them and delete tham. if any clarification is needed let me know because i am not great at explaining my issues.

cheers

 

Take a look at the VB script to delete profiles at this url:

The Shonk Project

Posted

You'll have to change some paths around for Windows Vista/7, but this works. You can even set folders that you don't want deleted.

 

Call DoStuff

Sub DoStuff

Const LocalDocumentsFolder = "C:\Documents and Settings\"

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

If MsgBox("Nuke local profiles?", vbQuestion + vbYesNo) = vbYes Then
	'Do Nothing
Else
	Exit Sub
End If

On Error Resume Next

For Each fldr in objFolder.SubFolders
	If Not isexception(fldr.name) Then
		objFSO.DeleteFolder fldr.path, True
		
		intCount = intCount + 1
	End if
Next

MsgBox "Operation completed. " & intCount & " local profile directories deleted."

End Sub

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 "tech"
		isException = True
	case "administrator.DOMAIN"
		isException = True
	case Else
		isException = False
End Select
End Function

  • Thanks 1

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...