Jump to content

Recommended Posts

Posted

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

  • Thanks 4
  • 5 weeks later...
Posted
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.
Posted
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:)
Posted
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)?
Posted (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 by ChrisP
  • Thanks 1
Posted

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!

Posted
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 ?
  • Thanks 1
Posted
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?
Posted

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. :D

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...