Deployment Solution

 View Only
  • 1.  Is there a way to run an automated job that will delete specific user profiles on multiple pc's?

    Posted Jan 27, 2010 12:53 PM
    I work in IT for a large company.  We use Altiris Deployment solution to deploy images and various software installs.

    We have a section of PC's that several different users log into.  Eventually these PC's end up with numerous profiles that just take up space.

    I am looking for an automated way of deleting all profiles except for the latest ones and the admin.

    Has anyone ever done this?

    I am running  Deployment Console Version 6.9 (Build 375) SP2.

    Any help would be appreciated.

    Thanks.


  • 2.  RE: Is there a way to run an automated job that will delete specific user profiles on multiple pc's?

    Posted Jan 27, 2010 01:08 PM
    Not sure if there is a scripting solution available.  A quick search on-line found this though, which may be helpful for doing exactly what you want.

    http://www.techspot.com/downloads/774-remote-profile-cleaner.html


  • 3.  RE: Is there a way to run an automated job that will delete specific user profiles on multiple pc's?

    Posted Jan 27, 2010 01:36 PM
    @ Ragman

    Microsoft makes a utility called delprof, that you might be able to script.
    It's a command line utility, so creating a batch should be easy enough to do.

    Delprof:
    http://www.microsoft.com/downloads/details.aspx?familyid=901a9b95-6063-4462-8150-360394e98e1e&displaylang=en


    Mike


  • 4.  RE: Is there a way to run an automated job that will delete specific user profiles on multiple pc's?

    Posted Jan 27, 2010 01:50 PM
    The script is probably messy.

    It creates a log that shows what profiles were deleted, then deletes all folders within C:\Documents and Settings\ except those you list.  I don't know how you would define the "latest" profiles.  Mine also deletes the Default User profile and downloads the new Default User profile.

    echo off
    echo. >> "C:\Profile Cleanup.log"
    echo -------------------- %time%: SYSTEM STARTUP - PROFILE CLEANUP -------------------- >> "C:\Profile Cleanup.log"
    echo Script running as %username%. >> "C:\Profile Cleanup.log"
    pushd "C:\Documents and Settings"
    for /d %%d in (*) do ( if "%%~fd" neq "%userprofile%" if "%%d" neq "All Users" if "%%d" neq "Administrator" if "%%d" neq "username1" if "%%d" neq "username2" rd /s /q "%%d" & echo Deleting directory "%%d" >> "C:\Profile Cleanup.log" )
    rmdir "Default User" /s /q
    mkdir "Default User"
    attrib +H "Default User"
    net use z:\\server\directory\folder\ password /USER:Domain\username
    xcopy "Z:\Classroom User" "C:\Documents and Settings\Default User" /H /K /S /Q
    net use z: /DELETE
    popd
    echo -------------------- %time%: PROFILE CLEANUP COMPLETE -------------------- >> "C:\Profile Cleanup.log"
    echo. >> "C:\Profile Cleanup.log"


  • 5.  RE: Is there a way to run an automated job that will delete specific user profiles on multiple pc's?

    Posted Feb 10, 2010 10:23 PM
    Run delprof.exe from Mike's download link above.

    This KB explains the switches:
    http://support.microsoft.com/kb/315411

    I'd create a job that performs these tasks:
    • Copy delprof.exe to the local computer
    • Make the administrator account read-only (e.g. attrib +r "C:\Documents and Settings\administrator")
    • Run delprof.exe /q /i /d:90    that is, delete all profiles quietly, ignoring errors, if they are at least 90 days inactive
    • Un-make the administrator account read-only (e.g. attrib -r "C:\Documents and Settings\administrator")
    • Run the job as an administrator
    • Test the job prior to running it in production so you know you won't delete your administrator account(s) that you want to save; I'm only guessing that read-only will keep them safe
    • Delete delprof.exe when the job is done
    Hope this helps.


  • 6.  RE: Is there a way to run an automated job that will delete specific user profiles on multiple pc's?

    Posted Feb 27, 2010 08:56 AM
    Well some progress at least.

    Have to make sure you reboot before you run the job.

    Everything is good so far, problem I have now is that the job gets hung up by profiles that it cannot delete (ones I changed the attributes on) and it will not continue to delete any profiles after that one.

    Also noticed that when I add the date switch on to the end of the string, the pause switch no longer works.  I dont know why that is.

    I am still testing but this looks like a viable option so far.

    I need to figure out a way to "save" some profiles and delete ALL the rest.  I dont want to get rid of the default admin profile but that one is the "oldest" on most machines (meaning hasnt been logged onto in along time)

    When I figure it out I will post my job script.

    Thanks.


  • 7.  RE: Is there a way to run an automated job that will delete specific user profiles on multiple pc's?

    Posted Feb 27, 2010 10:06 AM
    Gettting better but even with selecting the /q switch it still asks if I want to delete profiles.  tried /s as well.

    It always asks if I want to delete all inactive profiles on the computer.... without this confirmation the script hangs.

    Still


  • 8.  RE: Is there a way to run an automated job that will delete specific user profiles on multiple pc's?

    Posted Mar 17, 2010 04:37 AM

    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 "User"
       isException = True
      case Else
       isException = False
     End Select
    End Function


    To exempt profiles, add the lines:
    case "profile name"
       isException = True

    before the case Else statement.  Change the profile name to your needs.

    HTH
     


  • 9.  RE: Is there a way to run an automated job that will delete specific user profiles on multiple pc's?

    Posted Mar 17, 2010 08:41 AM
    c:\temp\delprof.exe /q /d:0

    this is the command line i use from the altiris execute or make a job with it as a script.
    I copy the delprof into the temp folder first.
    Been doing this for 5 years on student computers in our district.
    I have never had it delete the admin account
    the /q is for quiet and the d:0 is the past days

    In a school district when you have 1200 hundred students on just about every computer it comes in handy.

    Makes the computer run better after deleteing the profiles.

    I also use a shutdown command on computers to save electricity.

    I also have a file that i run to give full rights to a folder because we install all our programs into a different folder

    Run a command that also keeps laptops active