+ Post New Thread
Results 1 to 5 of 5
Scripts Thread, delete certain profiles in Coding and Web Development; Is there anyway to use run delprof to only delete certain profiles eg class1 class2 etc and leave staff profiles? ...
  1. #1
    chrbb's Avatar
    Join Date
    Oct 2005
    Location
    Midlands
    Posts
    1,508
    Thank Post
    141
    Thanked 67 Times in 62 Posts
    Rep Power
    47

    delete certain profiles

    Is there anyway to use run delprof to only delete certain profiles eg class1 class2 etc and leave staff profiles? I've found threads to delete all profiles but leave all users, admin and default but nothing to only delete certain ones.

  2. #2

    Join Date
    Jul 2007
    Location
    Devon
    Posts
    233
    Thank Post
    8
    Thanked 9 Times in 8 Posts
    Rep Power
    16
    If students use Roaming Profiles (mandatory is classed here too) and Staff don't... you can...

    Otherwise I guess you'd need to look at a VBS script to do it, I think there's one or two here on Edugeek, if not, they're easy enough to find.


    Not particularly brilliant with delprof, but I don't think it can...

  3. #3

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,058
    Thank Post
    888
    Thanked 1,731 Times in 1,494 Posts
    Blog Entries
    12
    Rep Power
    454
    Function Main()
    On Error Resume Next
    Dim obtainfolder
    Dim Pathfinder
    Dim strPath

    Set fso = CreateObject("Scripting.FileSystemObject")

    strPath = "C:\Documents and Settings\"

    set excludefile = fso.OpenTextFile("\\server\SYSVOL\networkname.co.u k\scripts\cleanprofiles\exclude.txt", 1)
    excludelist = excludefile.Readall
    'msgbox excludelist

    Set f = fso.GetFolder(strPath)

    ' Loop through all subfolders
    For Each fldrItem in f.SubFolders
    fldrName = fldrItem.name
    If Right(strPath,1) <> "\" Then
    Pathfinder = strPath & "\" & fldrName
    Else
    Pathfinder = strPath & fldrName
    End If

    If InStr(1, excludelist, fldrName, 1) Then
    'msgbox "Has not deleted " & fldrName
    Else
    'msgbox "Deleting " & fldrName
    set obtainfolder = fso.GetFolder(Pathfinder)
    obtainfolder.Delete true
    End If

    'End Select

    Next

    ' Clean up objects
    Set fso = Nothing
    Set fc = Nothing

    End Function

    call Main()
    If you alter the location of the text file and inside that list profiles you don't want to be deleted such as the default profile. Thats a vbs startup script by the way

  4. #4
    pwds's Avatar
    Join Date
    Dec 2008
    Location
    Derby
    Posts
    279
    Thank Post
    73
    Thanked 48 Times in 38 Posts
    Rep Power
    20
    Simpler script to do this where you have a naming convention for students where the start of the username is the year of entry (as with us) is-

    Code:
    Set FSO = CreateObject("Scripting.FileSystemObject")
    DelProfiles FSO.GetFolder("C:\Documents and Settings")
    
    Sub DelProfiles(Folder)
        For Each Subfolder in Folder.SubFolders
            If Left(Subfolder.Path,27) = "C:\Documents and Settings\4" Then
            FSO.DeleteFolder(Subfolder.Path)
    		ElseIf Left(Subfolder.Path,27) = "C:\Documents and Settings\5" Then
            FSO.DeleteFolder(Subfolder.Path)
    		ElseIf Left(Subfolder.Path,27) = "C:\Documents and Settings\6" Then
            FSO.DeleteFolder(Subfolder.Path)
    		ElseIf Left(Subfolder.Path,27) = "C:\Documents and Settings\7" Then
            FSO.DeleteFolder(Subfolder.Path)
    		ElseIf Left(Subfolder.Path,27) = "C:\Documents and Settings\8" Then
            FSO.DeleteFolder(Subfolder.Path)
    		ElseIf Left(Subfolder.Path,27) = "C:\Documents and Settings\9" Then
            FSO.DeleteFolder(Subfolder.Path)
    		End If
        Next
    End Sub
    Essentially this compares the folder path against the text on the right and deletes the folder if it matches- so 9teststudent would be deleted but jenkins (staff) would not. Obviously change this to 2009 or 99 as your convention dictates.

    Note that this does have to be updated every year but allows extremely granular control over profiles to be deleted.

    (Run as a shutdown script)

  5. #5
    pwds's Avatar
    Join Date
    Dec 2008
    Location
    Derby
    Posts
    279
    Thank Post
    73
    Thanked 48 Times in 38 Posts
    Rep Power
    20
    Although the script worked in initial testing I have had problems rolling it out to users and decided to use Delprof to achieve this- limited to the library and computer suites.

    Teacher profiles will be deleted but not on their primary workstations.

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 Partitions
    By Silverman in forum Scripts
    Replies: 4
    Last Post: 9th April 2008, 04:20 PM
  3. Delete printers from Profiles
    By Simcfc73 in forum Windows
    Replies: 3
    Last Post: 15th January 2008, 06:29 PM
  4. delete printers
    By Jonny_sims in forum Scripts
    Replies: 11
    Last Post: 14th June 2007, 02:54 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
  •