+ Post New Thread
Results 1 to 14 of 14
Scripts Thread, Script to Delete Profiles - PLEASE HELP in Coding and Web Development; hi all, i really need a script or .bat file or something that can delete the contense of the Documents ...
  1. #1
    Mr_M_Cox's Avatar
    Join Date
    May 2007
    Location
    Portsmouth
    Posts
    155
    Thank Post
    5
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Script to Delete Profiles - PLEASE HELP

    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

  2. #2

    Join Date
    May 2007
    Location
    Glasgow
    Posts
    8
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: Script to Delete Profiles - PLEASE HELP

    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.

  3. #3
    ICT_GUY's Avatar
    Join Date
    Feb 2007
    Location
    Weymouth
    Posts
    2,266
    Thank Post
    656
    Thanked 283 Times in 204 Posts
    Rep Power
    104

    Re: Script to Delete Profiles - PLEASE HELP

    User Hive Cleanup service is the MS app you need.

    http://www.microsoft.com/downloads/d...displaylang=en

  4. #4
    Mr_M_Cox's Avatar
    Join Date
    May 2007
    Location
    Portsmouth
    Posts
    155
    Thank Post
    5
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Script to Delete Profiles - PLEASE HELP

    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

  5. #5
    tosca925's Avatar
    Join Date
    Aug 2005
    Location
    Midlands
    Posts
    1,547
    Thank Post
    4
    Thanked 4 Times in 4 Posts
    Rep Power
    22

    Re: Script to Delete Profiles - PLEASE HELP

    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()

  6. Thanks to tosca925 from:

    Pumaedition (22nd April 2008)

  7. #6
    tosca925's Avatar
    Join Date
    Aug 2005
    Location
    Midlands
    Posts
    1,547
    Thank Post
    4
    Thanked 4 Times in 4 Posts
    Rep Power
    22

    Re: Script to Delete Profiles - PLEASE HELP

    Sorry, double post when our shi*e internet was playing up.

  8. #7
    tosca925's Avatar
    Join Date
    Aug 2005
    Location
    Midlands
    Posts
    1,547
    Thank Post
    4
    Thanked 4 Times in 4 Posts
    Rep Power
    22

    Re: Script to Delete Profiles - PLEASE HELP

    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()

  9. #8
    tosca925's Avatar
    Join Date
    Aug 2005
    Location
    Midlands
    Posts
    1,547
    Thank Post
    4
    Thanked 4 Times in 4 Posts
    Rep Power
    22

    Re: Script to Delete Profiles - PLEASE HELP

    Can a admin delete these multi posts for me please..............


    Bloody LEA internet. :twisted:

  10. #9

    Join Date
    May 2007
    Location
    Glasgow
    Posts
    8
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: Script to Delete Profiles - PLEASE HELP

    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.

  11. #10

    Join Date
    Jan 2006
    Location
    Surburbia
    Posts
    2,178
    Thank Post
    74
    Thanked 307 Times in 243 Posts
    Rep Power
    115

    Re: Script to Delete Profiles - PLEASE HELP

    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]

  12. #11

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,811
    Thank Post
    3,327
    Thanked 1,056 Times in 977 Posts
    Rep Power
    365

    Re: Script to Delete Profiles - PLEASE HELP

    If you take a look at this thread from before :

    http://edugeek.net/index.php?name=Fo...iewtopic&t=405

  13. #12

    Join Date
    Dec 2010
    Location
    Ellensburg, WA
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    VB Script to delete profiles

    Quote Originally Posted by Mr_M_Cox View Post
    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

  14. #13
    Duke5A's Avatar
    Join Date
    Jul 2010
    Posts
    807
    Thank Post
    83
    Thanked 132 Times in 115 Posts
    Blog Entries
    8
    Rep Power
    32
    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.

    Code:
    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

  15. Thanks to Duke5A from:

    jjd81 (26th February 2013)

  16. #14

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,811
    Thank Post
    3,327
    Thanked 1,056 Times in 977 Posts
    Rep Power
    365

SHARE:
+ Post New Thread

Similar Threads

  1. Script to delete profile at log off?
    By woody in forum Windows
    Replies: 74
    Last Post: 15th February 2013, 02:28 PM
  2. Replies: 1
    Last Post: 21st December 2007, 06:27 PM
  3. Replies: 8
    Last Post: 17th November 2007, 09:04 PM
  4. need a script to delete shortcuts
    By philtomo-25 in forum Scripts
    Replies: 2
    Last Post: 1st November 2007, 03:50 PM
  5. Script to delete printer
    By tosca925 in forum Scripts
    Replies: 2
    Last Post: 31st August 2005, 07:45 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
  •