Solved

VBS to delete old profiles

Posted on 2008-10-23
13
2,365 Views
Last Modified: 2013-11-10
I need a vb script that will delete all user profiles that have not been accessed within the last 90 days.  The script should exclude required profiles (Administrator, All Users, Default User, etc) but delete all older folders and files.  This script will be pushed out to 500+ machines, so it needs to be fully automated.  I've looked around and found similar scripts, but have been unable to modify them to do exactly what I need.  We do not use Roaming Profiles in our environment.  Thanks in advance!
0
Comment
Question by:BalchBingham
  • 5
  • 5
  • 3
13 Comments
 
LVL 18

Accepted Solution

by:
exx1976 earned 300 total points
ID: 22788447
Download this

http://www.microsoft.com/downloads/details.aspx?familyid=901a9b95-6063-4462-8150-360394e98e1e&displaylang=en


Then simply run


DelProf /I /D:90

That will delete every profile that hasn't been accessed in 90 days and will ignore errors.  The executable is standalone, so you can push it in a login script.

Enjoy!
0
 
LVL 4

Expert Comment

by:futurefiles
ID: 22788526
what about if the profiles are stored on a different volume? like with roaming profiles?
0
 

Author Comment

by:BalchBingham
ID: 22788653
That utility works great if I wanted to delete all profiles that haven't been used in X number of days, but I need to exclude certain admin profiles so that they are not deleted.  Is there a switch I can add to the command line?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 18

Expert Comment

by:exx1976
ID: 22788883
I have never seen it delete all users or default user.  I'm not sure about the administrator profile.

I do know that you need to either use RunAs or be logged on as an administrator in order to run it though..  ?

Perhaps give it a shot on one machine and see if it does what you want?  I've been using it for years on terminal servers and Citrix servers (in conjunction with UPHClean) to keep the drive space under control, and it works great.

@Futurefiles - he said he doesn't use roaming profiles..
0
 
LVL 4

Expert Comment

by:futurefiles
ID: 22789020
no but i do so i wondered if it could help me
0
 
LVL 18

Expert Comment

by:exx1976
ID: 22789085
Oh.  LOL

In that case, I doubt it.  I use roaming profiles for my users, and this utility only cleans up the local copies of them.

For instance, when I was running TS, I had 500 users logging into 6 TS boxes.  Sometimes the users wouldn't log onto one of the boxes for weeks at a time (but would log onto other ones - it was an NLB group).  So every night, I ran delprof /I /D:7 to remove all the locally cached profiles that were older than 7 days.  Kept enough free space on the disk for the servers to survive longer than they otherwise would have (only had 18GB disks).  But, the roaming profiles that were centrally stored on the file server were untouched, meaning that the next time the user logged in, the profile just copied down to the TS box again.

0
 
LVL 4

Expert Comment

by:futurefiles
ID: 22789123
thought so, thanks
0
 

Author Comment

by:BalchBingham
ID: 22789554
You're right, it doesn't delete the Default User or All Users profile, but we have a local admin account stored locally on each computer that needs to remain so that we can log into the machine in case it falls off the domain.  Other than that, the utility does exactly what I need it to.  Thanks for your help on this.
0
 
LVL 18

Expert Comment

by:exx1976
ID: 22789705
Just because the profile is deleted doesn't mean the ACCOUNT is deleted..  Is there anything that important in the profile?  If so, perhaps just script to move those programs/shortcuts to a different directory?

0
 

Author Comment

by:BalchBingham
ID: 22789792
There's not necessarily anything important in the profile, but can you clarify what you mean about the account not being deleted?  Our purpose in cleaning out the Docs and Settings folder is because we've noticed a performance issue when more than 10 or so profiles are being stored.  In our environment, we have "floaters" that will sit at a users desktop for a week or so while the normal user is out.  So over time, we will get computers with 30+ profiles being stored locally, most of which were only accessed once and will never be touched again.
If deleting the profiles leaves the account behind, will we continue to see these performance issues?
0
 
LVL 18

Assisted Solution

by:exx1976
exx1976 earned 300 total points
ID: 22789829
I think you're confusing profile and account...


You're worried about running this utility and it deleting the local administrator's account.  It will not.  What will happen is when you login with the local administrator's account, it'll be just like the first time you logged into the computer "Creating your profile, configuring IE", all that crap.

Your "floaters", I'm assuming, have DOMAIN accounts, not LOCAL accounts.  Ergo, yes, what you are really after is to remove the profile information, not the account information.  This utility removes profile information.

0
 

Author Comment

by:BalchBingham
ID: 22789875
Excellent, exactly the information I was looking for.  Thank you!!
0
 

Author Closing Comment

by:BalchBingham
ID: 31509309
Thanks for all your help!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question