+ Post New Thread
Results 1 to 10 of 10
Windows 7 Thread, Deleting profiles in Technical; I'm looking at Windows 7 to replace some of our old XP machines. One of the things I haven't found ...
  1. #1

    Join Date
    Mar 2007
    Posts
    421
    Thank Post
    14
    Thanked 16 Times in 10 Posts
    Rep Power
    18

    Deleting profiles

    I'm looking at Windows 7 to replace some of our old XP machines. One of the things I haven't found a way of doing is removing old profiles from the PC on reboot.

    In our current XP system (no roaming profiles, with the local Default user profile configured per PC type) we run a script on machine startup to delete any profiles that belong to students etc but leaves system profiles/admin profiles etc.

    Obviously this doesn't work with Windows 7 or Vista as any deleted profiles means the user cannot login without errors the next time.

    Is there a way to remove profiles like this in Windows 7? Basically I want the 'clean start' mechanism I have now - plus preventing the PC from having 100s of profiles stored on it.

  2. #2
    pwds's Avatar
    Join Date
    Dec 2008
    Location
    Derby
    Posts
    279
    Thank Post
    73
    Thanked 48 Times in 38 Posts
    Rep Power
    20
    I've heard there is a GPO setting that does that in Server 2008 (may well be included on the ADMX for Windows 7)-

    Computer Configuration->(Policies (WS2K8 only)->)Administrator Templates->System->User Profiles

    Can either delete after a certain number of days or not store them at all from what I've read.

  3. Thanks to pwds from:

    GoldenWonder (10th February 2010)

  4. #3

    Join Date
    Mar 2007
    Posts
    421
    Thank Post
    14
    Thanked 16 Times in 10 Posts
    Rep Power
    18
    Thanks - I'll have a look at that as soon as my Windows 7 admin PC is alive again!

  5. #4
    ckuntz01's Avatar
    Join Date
    Nov 2009
    Posts
    18
    Thank Post
    1
    Thanked 5 Times in 5 Posts
    Rep Power
    10
    Would you mind sharing the script that you use on Windows XP? I want to something VERY similar to that.

    Thanks in advance.

  6. #5
    Craggus2000's Avatar
    Join Date
    May 2008
    Location
    Chelmsford
    Posts
    63
    Thank Post
    1
    Thanked 8 Times in 5 Posts
    Rep Power
    14
    Quote Originally Posted by ckuntz01 View Post
    Would you mind sharing the script that you use on Windows XP? I want to something VERY similar to that.

    Thanks in advance.
    Is this any help? A batch file that deletes all but specified profile folders...

    Code:
    @echo off
    
    rem ***Created by CW 21-08-2007***
    rem ***Modified by CW 20-08-2008***
    rem ***Clear out all locally stored profiles on a workstation***
    
    
    title Remove Local Profiles
    dir /b/ad "C:\Documents and Settings" > %temp%\allusers.txt
    find /v /i "Administrator" < %temp%\allusers.txt > %temp%\allusers1.txt
    find /v /i "All Users" < %temp%\allusers1.txt > %temp%\allusers2.txt
    find /v /i "Default User" < %temp%\allusers2.txt > %temp%\allusers3.txt
    find /v /i "LocalService" < %temp%\allusers3.txt > %temp%\allusers4.txt
    find /v /i "NetworkService" < %temp%\allusers4.txt > %temp%\allusers5.txt
    find /v /i "user" < %temp%\allusers5.txt > %temp%\allusers6.txt
    find /v /i "Xp user" < %temp%\allusers6.txt > %temp%\allusers7.txt
    echo.
    echo.
    cls
    echo.
    echo.
    echo Deleting all locally stored profiles,
    echo except Administrator, All Users, Default User, LocalService, NetworkService, user, and XP User.
    echo.
    echo Please wait...
    echo.
    for /f "tokens=*" %%U in (%temp%\allusers7.txt) do (
    rmdir /q /s "C:\Documents and settings\%%U" )
    del /f /q %temp%\allusers*.txt
    echo.
    echo Operation complete.
    pause
    exit

  7. 2 Thanks to Craggus2000:

    ckuntz01 (10th February 2010), stariq (10th February 2010)

  8. #6
    ckuntz01's Avatar
    Join Date
    Nov 2009
    Posts
    18
    Thank Post
    1
    Thanked 5 Times in 5 Posts
    Rep Power
    10
    Thanks I will check it out.

  9. #7
    stariq's Avatar
    Join Date
    Feb 2008
    Location
    Birmingham
    Posts
    190
    Thank Post
    113
    Thanked 18 Times in 16 Posts
    Rep Power
    16
    just what we were after; cheers mate

  10. #8
    Craggus2000's Avatar
    Join Date
    May 2008
    Location
    Chelmsford
    Posts
    63
    Thank Post
    1
    Thanked 8 Times in 5 Posts
    Rep Power
    14
    You're welcome

  11. #9

    Join Date
    Mar 2007
    Posts
    421
    Thank Post
    14
    Thanked 16 Times in 10 Posts
    Rep Power
    18
    This is the vb script I use- very similar to above:

    Code:
    Dim fso, f, f1, fc, folderspec, strName
     
    folderspec = "C:\Documents and Settings"
     
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.GetFolder(folderspec)
    Set fc = f.SubFolders
    
    For Each f1 in fc
        CheckNames(f1.name)
    Next
    
    Set fso = Nothing
    
    Sub CheckNames(strName)
     
         If Ucase(strName) = "DEFAULT USER" Then Exit Sub
         If Ucase(strName) = "NETWORKSERVICE" Then Exit Sub
         If Ucase(strName) = "LOCALSERVICE" Then Exit Sub
         If Ucase(strName) = "ALL USERS" Then Exit Sub
         If UCase(strName) = "ADMINISTRATOR" Then Exit Sub
         ' Add as many of these as you need -one for each profile you DON'T want to delete!
      
         On Error Resume Next
         fso.DeleteFolder folderspec & "\" & f1.name, True
    
    
    End Sub
    I've got this running on machine startup - its worked a treat for around 5 years now!

  12. #10
    pwds's Avatar
    Join Date
    Dec 2008
    Location
    Derby
    Posts
    279
    Thank Post
    73
    Thanked 48 Times in 38 Posts
    Rep Power
    20
    As per the OP's post you should be aware that these scripts may have a consequence of preventing the user whose profile you deleted from logging on again in Windows 7 and Vista.

    Deleting the directory does not remove the user from the computer entirely and Windows is expecting the profile to be in that location- when it isn't it won't allow the user to log on. The usual System Properties -> Advanced route is supposed to work and I have read about GPOs (see earlier in the thread) but have no real life experience of either.

    I do know firsthand that people have had problems with their legacy scripts on Windows Vista/7 though and although I'm sure everyone else in the thread is aware of this I just want to labour the point in case someone googling takes the advice from here and applies it to a Vista/7 setting.

SHARE:
+ Post New Thread

Similar Threads

  1. Deleting Local Profiles
    By Mr_M_Cox in forum Windows
    Replies: 43
    Last Post: 17th March 2009, 02:02 PM
  2. deleting profiles
    By Millsy79 in forum Windows
    Replies: 7
    Last Post: 31st July 2008, 07:40 PM
  3. Deleting Roaming Profiles
    By Neville in forum Windows
    Replies: 9
    Last Post: 11th March 2008, 10:33 AM
  4. Deleting profiles on server
    By pinemarten in forum General Chat
    Replies: 4
    Last Post: 29th August 2006, 08:44 PM
  5. Deleting User Profiles
    By Gordie in forum Scripts
    Replies: 4
    Last Post: 19th June 2006, 03:41 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
  •