Novell is now a part of Micro Focus

Creating a Batch File to Remove Home Directories

Novell Cool Solutions: Trench
By Alan Coutts

Digg This - Slashdot This

Posted: 17 Jul 2003

The Task

In a school/College environment, potentially hundreds of eDirectory accounts may have to be deleted at the end of each year. Here's a way to locate and remove the associated home directories. Other suggestions have been posted on the School Cool Solutions, but it does no harm to have another one.

The Solution

This method relies on a particular NDS design, whereby you wish to delete all users from a particular OU. In my case, we group users by year and each year delete all year-6 pupils.

Before carrying any of this out, make sure you have a reliable backup.

  1. Download and install the "ODBC driver for eDirectory" from
  2. Select the relevant context within the "Data Source Setup" section of the "ODBC Data Source Administrator" in the Windows Control Panel.
  3. Open Excel.
  4. Select "Data", "Get External Data", "New Database Query".
  5. Choose the Data Source created earlier.
  6. In the left hand column, expand "UserNDS" and double click on "Home Directory_Path".
  7. Click Next, Next, Next, Finish to return data to Excel.
  8. Move the data into column B or insert a new column as Column A.
  9. Delete the first row (Home Directory_Path).
  10. In cell A1, type "rmdir /s /q" and copy the command all the way down.
  11. Save the file as file type "Text (MS-DOS)" with a bat extension.
  12. Map a drive to the root of the volume where the home directories exist.
  13. Open a command window and copy the newly created batch file to the recently mapped drive.
  14. Run your new batch file and watch the home directories disappear.

Step 10 presumes you are using a WinNT workstation. If using Windows 98, the command is "deltree /y".

If you have questions for Alan, you can contact him at

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© Copyright Micro Focus or one of its affiliates