Remove all profiles on startup

Occasionally Windows XP manages to stuff up its roaming profile, when this happens, resolving profile related problems can be difficult.  Schools running Community Connect 3 will benefit from the “Reset Profile” option in the System Management Console, however, profile problems may quickly return, as they often remain on several workstations. To help cure this problem…

Occasionally Windows XP manages to stuff up its roaming profile, when this happens, resolving profile related problems can be difficult.  Schools running Community Connect 3 will benefit from the “Reset Profile” option in the System Management Console, however, profile problems may quickly return, as they often remain on several workstations.

To help cure this problem on an RM Community Connect 3 network, there is a system in place called station tidy.  This is supposed to clean user profiles when they reach a certain age, however there have been reports that this does not work correctly.  So to to ensure that a users profile problems will not return is not guaranteed.

There is however a possible answer.  It is a quick and dirty(ish) script that will delete all folders in C:\Documents and Settings, with the exception of system folders that are quite important.  The script has been coded taking advantage that the computers “System” account has full control of all files and folders in the Documents and Settings folder.

Why not use the Microsoft DELProf utility?  Yes why not indeed.  Through personal experience I have found that the DELProf utility doesn’t always delete stale user profiles, it seems quite random and doesn’t explain why it has left profiles that are clearly over x number of days old.  This is particularly the case when a domain account has been deleted.

If you are having problems with profiles building up on your workstations, then this might help.  Note however that this only deletes folders from the Documents and Settings folder on the hard disk and does not attempt to clean up the Windows Registry that also contains references to the profile folders.\r\n

  1. On the file server, open Active Directory Users and Computers.
  2. Browse to the Organisational Unit that contains the computers that you wish to clear the profiles from. (Do NOT put this at the domain level, as this will then run on your domain controllers and produce undesirable results)
  3. Right Click on the Organisation Unit and choose the properties menu.
  4. Choose the Group Policy Tab, and click the New button.
  5. Give the policy a meaningful name “Delete Profiles from Workstations” for example
  6. Double click on to edit the new policy.
  7. Browse to Computer Configuration -> Windows Settings -> Startup/Shutdown Scripts -> Startup
  8. Right click on the empty part of the Group Policy Editor to add a new file.
  9. Click on the Show Files button.
  10. Now create a file called “cleanprofiles.vbs”
  11. Edit the file and paste the code from below (tip: copy it into wordpad first so that it retains formatting)
  12. Save and close the file.
  13. Back in Group Policy Editor, click on the Add button and select the script that you created.
  14. Close Group Policy.
  15. Allow the policy to propgate through the network then reboot the workstations.  It may require 2 reboots before the script runs.

When the script first runs, Windows XP will appear to hang on the “Running Computer Scripts” message, this is normal as it will have several hundred folders and files to delete.

The code is quite rough and is quite lazy in the way that it was coded.  If you need to exclude more profiles, you need to add an If Then End If block containing the name of the profile you wish to skip.  The script could also be modified so that folders that are x number of days old are deleted, rather than everything.

If you felt exceptionally talented, you could add code to tidy up the Windows Registry so that all traces of the profile are removed from the computer.  The key to tidy is HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList

ON ERROR RESUME NEXT
' Clears user profiles on computer startup
' leaves the following folders
' Administrator
' RM Default User
' Default User
' All Users
' ClassMate
' Reference : http://msdn2.microsoft.com/en-us/library/9kcx47hd.aspx
dim oktodelete, fso, f, foldercollection
set fso = CreateObject("Scripting.FileSystemObject")
set f = fso.getfolder("C:\\Documents and Settings")
set foldercollection = f.subfolders
for each folder in foldercollection
  oktodelete = true
  if instr(1, folder.path, "Administrator") then
    oktodelete = false
  end if
  if instr(1, folder.path, "RM Default User") then
    oktodelete = false
  end if
  if instr(1, folder.path, "Default User") then
    oktodelete = false
  end if
  if instr(1, folder.path, "All Users") then
    oktodelete = false
  end if
  if instr(1, folder.path, "ClassMate") then
    oktodelete = false
  end if
  if instr(1, folder.path, "LocalService") then
    oktodelete = false
  end if
  if instr(1, folder.path, "NetworkService") then
    oktodelete = false
  end if
  if oktodelete then
    'wscript.echo "Deleting Folder : " & folder.path
    fso.deletefolder folder.path, true
  end if
next

Similar Posts

  • Internet Explorer JavaScript not working

    On the Service Desk where I work had an interesting problem with Internet Explorer.  What was happening was that the user was able to visit a site, but items on the site, like roll-over images and pop-up windows did not work.  Another thing that didn’t work was the Users Applet from the Control Panel. At first we…

  • Getting a list of users that belong to a Windows Security Group

    Some times it is not always easy to see the name that you are looking for in a GUI list of users that Active Directory Users and Computers displays.  Using VB Scripting you can obtain a list of users from a Security group and output this to screen or to text file.

  • Security package error – Windows 10 RDP

    About the issue Users of the Remote Desktop client (MSTSC), may experience a “Security package error occurred in the transport layer” message when the connection is configured to use a Remote Desktop Gateway.  This condition is likely to occur when the client workstation access the internet via a proxy server. The HTTP Protocol The Remote…

  • Adding a Domain Account to a local security group

    Windows Scripting Host is a very powerful tool that allows you to use simple Visual Basic code syntax to change or customise settings of a computer.  This script will allow you to use Window Active Directory Group Policy to add a domain user account or group to a local security group of a Windows 2000/XP…