I can't delete Cygwin in my Windows 10 setup. I narrowed it down and the file that's causing trouble is
C:\cygwin\usr\share\avogadro\crystals\zeolites\CON.cif

- 25,431
- 8
- 61
- 93

- 77
- 1
- 1
- 6
-
1Try to ask [Super user](https://superuser.com/) instead. Unless you want to remove/unlock the file somehow programmatically? – pirho Nov 17 '17 at 21:03
-
@pirho I don't care how. I just want it deleted. – Owen Strand Nov 17 '17 at 21:07
-
Ok but my point was that this site is for programming problems and this seems to be some software/OS problem that belong s to Super User. See the link in prev comment. – pirho Nov 17 '17 at 21:09
-
You need cygwin to delete it ;O) command is: chmod 777 C:\cygwin\usr\share\avogadro\crystals\zeolites\CON.cif THEN: rm -f C:\cygwin\usr\share\avogadro\crystals\zeolites\CON.cif – Jon Goodwin Nov 17 '17 at 21:09
-
@JonGoodwin I don't fully have Cygwin. I started to download it, but I realized how much space it would take up, so I aborted. – Owen Strand Nov 17 '17 at 21:13
-
Use some UNIX tools that use less space like git bash (MING32) – Jon Goodwin Nov 17 '17 at 21:14
-
Perform a disk check: chkdsk C: and re-boot – Jon Goodwin Nov 17 '17 at 21:21
4 Answers
In my case why the cywin directory (folder) cannot be deleted was due to "access privilege". To delete the folder, the user needs to "take ownership" of this folder. It cannot be done easily in Windows GUI. It is, however, fairly easy to achieve in a command prompt window using three command lines.
I followed the steps posted in this link. Remeber to be very sure what you are doing. Take note that the command prompt DOS window must be opened as "administrator". What this link says:
Open DOS Window "cmd.exe" as "administrator". Issue to the command prompt the following lines:
takeown /f "c:\cygwin" /r /d Y
The last parameter makes takeown assume "yes" to all questions and depends on locale. In the author's locale he/she had to answer "J" to make it work.
icacls "c:\cygwin" /T /Q /C /reset
Finally, to delete the files after we got the relevant permissions:
rd "c:\cygwin" /s /q
This method should work as intended in Windows 7 and above. I tried it in Windows7-x64 and Windows10-x64.

- 789
- 9
- 11
-
1This worked for me on a *very* locked down machine. I had to substitute `c:\cygwin64` though. – zkent Nov 17 '19 at 20:24
-
1When I execute the first statement I get: Info: Access is denied. ( "c:\cygwin64\var\log\sshd.log" ) – gimmegimme Mar 20 '20 at 16:47
-
gimmegimme please check if your DOS prompt had been "opened as administrator". – coarist Dec 30 '21 at 12:16
-
zkent: yes, users should substitute "c:\cygwin" with the target path in which the Cygwin installation needs deleting - you have designated this in the past when installing Cygwin. – coarist Dec 30 '21 at 12:18
Running the following in command prompt as Administrator helped me:
C:\>del \\?\C:\cygwin64\usr\share\avogadro\crystals\zeolites
\\?\C:\cygwin64\usr\share\avogadro\crystals\zeolites\*, Are you sure (Y/N)? Y

- 21
- 2
I know this is a bit late but I like it:
If you have Linux subsystem installed (I have Ubuntu 18.04), you can remove that file via bash
without any of the above. Just do,
Win+r
-> bash
-> cd /mnt/c/cygwin64/usr/share/avogadro/crystals/zeolites
-> rm CON.cif
.
Problem with cmd.exe
and explorer.exe
are that they are Windows' programs, whereas bash
is not. In a way, this is the same as Lucian's answer because it makes the computer consider the file as a regular file.

- 111
- 1
- 7
Here it worked referring to PowerShell To Set Folder Permissions:
- replace
<User_with_administrator>
$mypath = ".\cygwin64--TO-BE-DELETED"
$myacl = Get-Acl $mypath
$myaclentry = "<User_with_administrator>","FullControl","Allow"
$myaccessrule = New-Object System.Security.AccessControl.FileSystemAccessRule($myaclentry)
$myacl.SetAccessRule($myaccessrule)
Get-ChildItem -Path "$mypath" -Recurse -Force | Set-Acl -AclObject $myacl -Verbose
Then the .\cygwin64--TO-BE-DELETED
can be deleted.

- 3,066
- 35
- 37