Fix: Invalid File Handle on Windows 10

When you are trying to delete a file or folder on your system, you might come across the error message ‘Invalid file handle’. This error message occurs when the name of the folder or the file that you are trying to delete is a reserved name. The Windows operating system doesn’t deal with certain names/nicks due to which the File Explorer prevents you from giving your folder or file a reserved name. However, in case you get the file from your smartphone or another operating system like Linux, you will be prompted the said error message upon trying to delete it.

Invalid File Handle

Microsoft Naming Conventions

The Microsoft Naming Conventions provide that files or folders on your system should not be named CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. This is because these names are reserved names in the Windows operating system, meaning they are used for a specific purpose by the Windows operating system and should not be used anywhere else. You should also avoid following the above names immediately by an extension, for example, NUL.txt. In case you want some more details, you can refer to this article on Microsoft’s website.

What causes the ‘Invalid File Handle’ Error Message on Windows 10?

Well, the reason for the emergence of the said error is quite clear after giving the Naming Conventions provided by Microsoft a read.

  • The Name of the File/Folder is a Reserved Name: The error message occurs appears when the file you are trying to delete is given a reserved name. Using reserved names is prohibited by Microsoft and should not be trifled with.

Now that you are aware of the Microsoft Naming Conventions and the cause of the error message, you can overcome it by following the solution given down below.

Deleting the File or Folder

The files that are given a reserved name can be rendered useless because you can’t use them neither are you able to delete them using the standard procedure. To delete the file or folder, you will need to rely on some command prompt commands.

If you are facing the error message while deleting a directory, you can do so by following the steps given down below:

  1. Press Windows Key + X and select Command Prompt (Admin) from the list to open an elevated command prompt.
  2. Once the elevated command prompt opens up, type in the following command:
    rd \\.\c:\documents\con /S /Q
    Deleting a Folder with a Reserved Name
  3. In the above command, replace the path accordingly, however, make sure you do not remove the ‘\\.’ before the path. Another example would be:
    rd \\.\E:\con /S /Q

The parameter /S is used to tell the rd command to remove all the sub-directories found in the specified directory while the /Q parameter is used to tell the command to remove contents of the specified directory silently (you won’t be given any prompts). Moreover, \\. is used to refer to the current system.

In case you are trying to delete a file, do the following:

  1. Open an elevated command prompt as shown above.
  2. Type in the following command and then hit Enter:
    del \\.\c:\Temp\con.txt
    Deleting a File with a Reserved Name
  3. To delete a file, you will just have to specify the extension of the file and use the command del instead of rd.

That’s it, you have probably deleted the file/folder from your system.

Kevin Arrows
Kevin is a dynamic and self-motivated information technology professional, with a Thorough knowledge of all facets pertaining to network infrastructure design, implementation and administration. Superior record of delivering simultaneous large-scale mission critical projects on time and under budget.

Expert Tip

Fix: Invalid File Handle on Windows 10

If the issue is with your Computer or a Laptop you should try using Restoro which can scan the repositories and replace corrupt and missing files. This works in most cases, where the issue is originated due to a system corruption. You can download Restoro by clicking the Download button below.

Download Now

I'm not interested