Delete Profiles via command line
If you are in an environment like me, a badly maintained Novel environment, you might come across a situation to use this.
Because of reasons I can’t go in to… I can’t re-image the workstations at the site I support to fix this the ‘right’ way. But finding ways to do things that work in a constrained environment is what I do best.
The issue: Lots of user profiles on workstation
There are about 300 systems with 20, 40, maybe even 60 user profiles stored on each of them.
Cause: Non volatile account setup
In Novel there are several ways of dealing with local Windows users. One of those ways is by using Dynamic Local users (DLU). This creates local windows users with the same name and password as their eDirectory accounts. There are potential problems with this approach.
If you have a large volume of users that will be using any one workstation you will want to check volatile users on the DLU policy. Because if you do not then profile data will remain stored for every individual user that logs in to that workstation. If it is checked then the profile data and user account is removed during logoff. Using DLU correctly does require some other prep-work too. Like, you will need to build a very good Default local user profile.
What if someone didn’t turn on the volatile account option? How do you fix it without re-imaging every system?
Solution: Delete Profile or Delprof
Delprof program is a Microsoft utility to delete user profiles on systems. It is distributed in an MSI directly from Microsoft. Download link: http://www.microsoft.com/download/en/details.aspx?id=5405
The greatest thing about delprof is that you don’t really need to install it on every computer. You only need to install it on one to get the delprof.EXE file from the install. It will work without all the other stuff it may or may not install.
Now that you have the EXE you can place it somewhere everyone in the network can have read access to it. Like the Public folder.
Here is where we start talking geeky.
Create a DelOldProf.bat file and call out our nice new and shiny delprof.exe file with some extra parameters. Just a caution… you can name your bat file anything you want… but never create a .bat with the same name as a .exe saved in the same folder and called by your .bat file. The .bat files won’t work right and you will be banging your head against a wall trying to figure out why. BEEN THERE DONE THAT… me = id-ten-t error.
Below is the full list of all the options you can use with this exe.
usage: DELPROF [/Q] [/I] [/P] [/R] [/C:\\] [/D:]
/Q Quiet, no confirmation.
/I Ignore errors and continue deleting.
/P Prompts for confirmation before deleting each profile.
/R Delete roaming profile cache only
/C Remote computer name.
/D Number of days of inactivity.
My command looked a little like this: \\server\sys\public\delprof.exe /Q /I /D:60
/Q because I want this to run without user intervention.
/I because I don’t care about errors. I am trying to sweep up the big dirt on this one. The small dust that might get left behind I couldn’t care less about.
/D:60 because if it is that many days old no one would care about it anymore. The number of days is up to you and how it works with your environment.
Save the nice batch file in your same public directory and add it to your Novell login script like this. #DelOldProf.bat
Next time someone logs-in… The big command screen will pop up and show everyone all the data it is deleting.
Note: You can hide some info from the users by adding a @ECHO OFF command in the first line of the .bat file before your commands. This turns off the prompt screen prints and will only display actual command outputs.
There are a few other things with this… This will delete your administrator profile if they exist. From my experience it will not delete the Default profile. This is something you really want not to happen and it should be restricted to read only just to be safe. There are commands that you can use to change that before the delprof if you are scared it isn’t set already.
Last thing I promise… I don’t see this as a long-term solution for the too many profiles thing in my case. But in the case of roaming profiles…use the /R as a great way to clear that cache after so many days to keep it from clogging up the systems.
I lied… one more… Always remember if you are adding and removing that much data on a workstation hard drive every day… make sure you are running a defrag at least weekly. I scheduled my workstations to do a 2 hour defrag three times a week.
Until the next tech thing…
Andrew Birchler