Delete unwanted profiles

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 16 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
itguy8423@yahoo.com
Posts: 2
Last visit: Wed May 23, 2007 5:57 am

Delete unwanted profiles

Post by itguy8423@yahoo.com »

I am looking at running a vb script at startup to delete all profiles on a machine except Administrator, Default User, and 2 custom user accounts (user and oasdguest). Anyone have any ideas? Basically, when the login screen comes up, the only user profiles that exist are Administrator, Default User, user, and oasdguest.

I am running Windows XP SP2 Professional in a Windows Server 2003 domain.

I have been looking online for quite awhile, but have had no luck.

Thanks.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Delete unwanted profiles

Post by jvierra »

The Windows Resource Kit contains a utility which can "correctly" delete profiles. It can be used to remove al roaming profiles which will be recreated at next logon. Tjis is , perhaps, teh best way to keep machines clean.

It can also be used to delete all local profiles that are not used by the system. This is not generally what you want so you would want to have it prompt for confirmation so you could skip the profiles you want to keep.

You can also add a switch that says to only delte profiles that haven't been used in n days. This utiity can be run against remote computers and could be run from a scrpit or batch file that gets computer names from a file or from Active Directory.

It is possible to just delete teh profile folders in a script however it will leave teh registry settings. DelProf cleans the registry too.

If you are talking about a home system or a standalone system that is using teh cute graphical logon screen tehn the registry cleanup is needed. If you delete teh old user accounts teh logon screen should reflect this. The profiles will remain and can be deleted directly.

Do not delete any system profiles. their are four or more system profiles that should not be deleted. If you delete them the system may become unusable.

User avatar
itguy8423@yahoo.com
Posts: 2
Last visit: Wed May 23, 2007 5:57 am

Delete unwanted profiles

Post by itguy8423@yahoo.com »

thanks for the info.

we have over 4000 computers and over 10000 potential users in our school district. so, i would like this script to run via group policy as a startup script. i would like it to run on every startup. prompting the users is of course not an option. the command/script would need to be silent. i am trying to delete these profiles to clean up the documents and settings directory, but more importantly, we have users that cannot get logged on at times because their profile has a locked file in it. we pretty confident this is happening because the user shuts down their system improperly and we use a mandatory profile.

I am not sure if i would need the registry cleaned up in this locked file scenario. Of course it would be nice. However, the research I have done on delprof.exe states you need to be logged on with a user who has admin rights, which I don't think would work in a startup script.

I don't know if any of this means anything to you or not, but again, Thank You for taking the time to respond :)
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Delete unwanted profiles

Post by jvierra »

As I pointed out. YOu can run the script remotely against any number of computers. I have done this many times. Just set the script to run on a subset - say 100 - overnight. YOu could increase it to 300 or 400 and have them done by morning in a fairly fast network.
The startup script can do this but I wouldn't want to unleash it without some testing. If yuo delete profiles not used for more than, say, 60 days on the first pass it would clean up quite a bit.

The locked file issue is because of a damaged file system or due to trojan or virus activity. It's usually the result of a process hooked into the user session that locks a file open. It can also be caused by a damaged user hive or an incompatible piece of software that locks the hive inmemory.

Install User Profile HIve cleanup service- downloadable frm MS and installable through group policy. This fixes most of these kinds of issues but not the virus/trojan or disk damage issues.

Schedule a disk check in GP and leave it set until you are sure all systems have been booted at least once. This will fix the disks in most cases.

In you environment you should schedule disk checks about once a week. You can do this by scheduling a diskcheck from taks scheduler to occur on weekends or overnight.

Disable a users right to shutdown the system. If you need to save power because you don't have "green" machines then schedule an automatic shutdown at teh end of the day. That will fix teh user crash issue.

On new XP machines and some olde W2K machines you can set the bios to do a shutdown when the power button is pressed. This will prevent rashing the system.
This topic is 16 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked