Windows Home Server Cleanup Tool

What problem does this software solve?

The problem: you have dozens or even thousands of files on your Windows Home Server that cannot be read due to an "invalid file handle" problem. You can delete each one individually, but it will take forever... You probably lost a hard disc or had a bad episode while removing a disc.

How it works

This tool is for Windows Home Server. It reads files on your Windows Home Server to test if they are readable. It is meant to solve the "Invalid File Handle" problem. It does this by testing if a file is readable. If it is not readable it:

  1. logs that event in C:\WHScleanup.log
  2. Writes the commands to delete that file in C:\WHScleanup.cmd
Once the application has finished running you can inspect the log file (which is actually in CSV format), and inspect the contents of the .cmd file prior to running it.

You must check the contents of the .cmd file prior to running it! I have found it to be correct, but you don't want to be surprised, upset or experience any unpleasant emotion after running it. If you don't feel OK about running it, then don't.

Running the .cmd will delete the reparse points, effectively deleting undeletable, unreadable files.

To see how it works, run it against your desktop computer on, say, the C:\temp directory. I trust that C:\WHScleanup.cmd will be empty afterwards.

Normally you run it on your WHS against D:\shares but you might just do it against one of your shared folders. eg D:\shares\music

You must run the application from a local disc on the WHS - not a network file share from a client PC. In other words, copy it to the C: drive on your WHS and run it under Remote Desktop.

If you do end up with entries in the .cmd file then go and take a look at a few of the relevant files on your server before you run the .cmd file. Try reading them or copying them. Try this with a few files.


Sometimes the .cmd file still can't delete the reparse points. That's a problem I can't solve. This seems to usually occur with filenames that use characters that are not native to the installed language on your WHS.


  1. Download the executable below
  2. Move it to the C: drive on your WHS
  3. Remote desktop into your WHS
  4. Double-click the exe
  5. Choose the directories to test. By default it will test all files on all shares.
  6. Click go.
  7. Wait until it is finished. You can monitor progress on the application or in the log and cmd files on the C: drive
  8. When finished, open the log in Excel or a database and take a look, especially at the result column.
  9. Open the WHScleanup.cmd file in Notepad or a text editor and examine the contents. Test a few files manually on your desktop pc by trying to copy them from the share on your WHS to your desktop. They will probably fail with the invalid file handle.
  10. When ready and satisfied, close the editor and double-click the .cmd file to execute it. It will delete the reparse points.


I, the author, am pretty sure this works well. The only way I can think of that it could adversely affect your files is if you run the C:\WHScleanup.cmd file without inspecting it, thinking about, and making an informed decision to run it. There may also be error events that I have not forseen and therefore not catered for in the code. If you can do better, then download the source code and improve and share it.

I expressly disclaim all liability for any adverse affects, direct or indirect, to your computer, files or any other thing, whether through negligence or otherwise from the use of this software. By using this software you agree to this disclaimer and hold me free of any claim in relation to the use of the software.

The source code is available on this site. You should satisfy yourself that it does what you want and what you expect. The compiled executable available on this site was compiled in Visual Studio 2005 from that code.

I advise a full backup of your entire server if you are the sort of person who will get upset at unnecessarily deleted files when you run the .cmd file. I don't think the .cmd files generated by this application will do that, but it MIGHT. You have no recourse to me, so it's all in your hands.

You should, by now, understand that you run this software and the generated .cmd file at your own risk.

If you have a problem, suggestion or a revised better version, post a message at


This work is licenced by catsaver under a Creative Commons Licence
Creative Commons License

Download (reviewed 10 Mar 2009)


Visual Studio Project