If you installed “cygwin64” earlier and want to delete the folder after uninstalling the tool, you may be unable to do so.
It may say, “Folder Access Denied.” This can happen if the NTFS permissions for the folder are tight or the profile that owned the folder no longer exists on the computer.
Resolution
Boot into Safe mode
Please try deleting the folder in Safe mode to rule out the “file-in-use” scenario. See How to Start Windows 10 or 11 in Safe Mode.
If the same error occurs in Safe mode, take ownership of the folder and delete it.
Use one of the methods below if Safe mode doesn’t help.
Take ownership and delete the folder
From an admin Command Prompt, run these commands to take ownership and delete the folder.
takeown /f "C:\cygwin64" /r /d y icacls "c:\cygwin64" /T /Q /C /reset icacls "C:\cygwin64" /grant administrators:F /T rd "C:\cygwin64" /s /q
Sometimes, you may get the error “Access is denied” when assigning permissions using Icacls.exe.
In that case, use the Trusted Installer Command Prompt.
Use Trusted Installer Command Prompt
Download AdvancedRun from Nirsoft.net and run it.
Using AdvancedRun, launch cmd.exe as “TrustedInstaller.”
In the TrustedInstaller Command Prompt, run:
rd /s /q "\\?\c:\cygwin64"
If that doesn’t help, try the WinRE method below.
Boot into WinRE
Boot into Windows RE using one of the methods in the article How to access Windows Recovery Environment.
From the login screen, click Shutdown, then hold down the Shift key while selecting Restart.
In WinRE, click Troubleshoot, Advanced Options, and Command Prompt.
Run:
bcdedit | find "osdevice"
Note the OS drive letter in the output. Assuming it’s C:\, run:
rd "C:\cygwin64" /s /q
If it’s D:\, run:
rd "D:\cygwin64" /s /q
If it says, “The device is not ready”, try the Windows internal syntax below:
rd "\\?\C:\cygwin64" /s /q
(or)
rd "\\?\D:\cygwin64" /s /q
If not, try the WinRAR method below to delete or rename the folder.
Install WinRAR
Please install WinRAR and run its executable as TrustedInstaller using AdvancedRun.
Using WinRAR’s file manager interface, please see if you can browse the contents of the Cygwin64 directory and its subfolders. Also, try renaming the “Cygwin64” directory to “demo” or something else. Browse the contents of the folder, or press Shift + Del to delete the folder permanently.
One small request: If you liked this post, please share this?
One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:- Pin it!
- Share it to your favorite blog + Facebook, Reddit
- Tweet it!