andrew_obrien Posted March 4, 2009 Posted March 4, 2009 Here is the script i use to remove profiles when a user logs on as we use roaming profiles for students but the local folder is still created. This removes it before anyon logs on. '*******Remove Profiles******** 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 '*******Folder you want to keep******* 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 Else isException = False End Select End Function 4
rh91uk Posted March 5, 2009 Posted March 5, 2009 Thanks for this Andrew - this has been very helpful in solving a problem.
leco Posted April 13, 2009 Posted April 13, 2009 This script looks interesting and maybe just what I'm looking for. Could someone please tell me how I make and run it, please? Where do I store it - Netlogon/scripts perhaps or somewhere else? I have a Win2008 64 bit server, functional level Win2003.
SYNACK Posted April 13, 2009 Posted April 13, 2009 (edited) This should provide some answers: Create System Startup / Shutdown and User Logon / Logoff Scripts just need to save it as a .vbs file in notepad, put in a network location as linked and add it to a gpo to apply it. Edited April 13, 2009 by SYNACK 1
leco Posted April 13, 2009 Posted April 13, 2009 Good job I'm on holiday, more time to read and digest. Thanks for this will do my homework and have a bash. This learning curve thingy is getting less steep:)
leco Posted April 13, 2009 Posted April 13, 2009 Some more questions on this which may or not be relevant. If this is a Logon/Logoff script can I still put it in an OU for machines? e.g. I have all the classroom computers in one unit in AD, can I apply the script to those machines even though this is a User script? Does that make sense or am I talking gibberish (through ignorance of the issue)?
ChrisP Posted April 15, 2009 Posted April 15, 2009 (edited) hi, just a couple of observations.. 1. delprof.exe is a very useful for sticking in batches ( got some handy switches /c: (remote computer) /d: (days inactive) etc.) 2. remember NEVER to run it on a laptop. lol 3. you can compound your case statements... select case foldername case "All Users", "Default User", "LocalService", "NetworkService", "Administrator" isException = True case Else isException = False End Select 4. to make it a bit more robust for a production environment it may be a good idea to rename the folder first, then delete. WHY? Ever tried to delete a profile and ntuser.dat was locked? then you had to restart to delete it? with the script as it is (and delprof for that matter) it would result in a half deleted (corrupt) profile. if you had a rename element in the script the rename function would fail and not proceed to delete the profile. Ergo the profile still works and when the PC is next rebooted the script should work as expected Edited April 15, 2009 by ChrisP 1
leco Posted April 15, 2009 Posted April 15, 2009 Please excuse my ignorance - why NEVER on a laptop? Thanks for the info though.
Polski Posted April 15, 2009 Posted April 15, 2009 I would imagine its because you would need a profile present, when not connected to the doamin, to successfully log in. Just a guess from the dark!
ssiruuk2 Posted April 15, 2009 Posted April 15, 2009 Im presuming because if they use a local login account for use away from the network it will delete all of their saved documents / pictures / music etc ? 1
leco Posted April 15, 2009 Posted April 15, 2009 thanks ssiruuk2, that kinda makes sense. Our laptop users have roaming profiles with offline folders, so might it have the same effect if a local cache had been created by the profile?
ChrisP Posted April 15, 2009 Posted April 15, 2009 thats correct When one of my technicians started he delproffed a laptop and blitzed a profile with 2 gigs worth of photos and documents. his next lesson was on file recovery.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now