Windows 7 – Can’t delete exe files on Desktop

During my testing of Windows 7 I have had almost no issues to report, the only things that have been of notice have been third party or driver related. Then there’s the permissions bug, this bug is so elusive that hardly anybody has reported it and nobody has a solution, not even me.

Update 1: It appears that as of build 7068 this bug may have been fixed, see comments below for details.

Update 2: There are reports the bug has reappeared in the RTM build, it can also occur in Windows Vista but slightly less often.

Update, September 2 2009: It has been mentioned below that this website has a possible fix and that it can fix both Windows Vista and Windows 7. I don’t get this bug any more on any of my machines so I am unable to verify it however.

The issue is fairly simple, occasionally after running a file from the Desktop or a subfolder thereof I am fairly certain the file does not have to be run first though, it just happens more often if it is, (usually a setup program, but can be something as simple as a small test application) upon attempting to delete the file you get:

1. The UAC dialog wishing to confirm the deletion pops up, you click Ok (if UAC is off or disabled then go to straight to step 2)
2. An error message pops up exclaiming that you must get permission from the owner, or that you must be an administrator, it will give you the option to try again or skip.
3. Clicking try again pops up the same message, over and over and over again.
4. The IT admin in you gets confused “But I am the administrator, my user is a member of the Administrators group”
5. There must be some mistake, you attempt to grant yourself ownership of the file by right clicking and….
6. Right clicking results in a wait of more than 30 seconds during which an attempt to do anything else in the explorer window will cause Windows to assume that it has at least temporarily stopped responding, also it will then cause the menu to disappear as soon as it comes back.
7. Once you have worked this out, you click Preferences and go to the security tab where you normally change ownership, upon viewing the ownership screen you stumble upon the message Current owner: Unable to display current owner, not uncommon when the file is created on another computer etc. On attempting to change owner to yourself you get the message ‘Access Denied’.
8. You go for more advanced deletion methods, unlocker, unlock, using the command line for every windows based ownership, takedown command you can find, nothing will make the file move.
9. You may give up, don’t worry the file will magically delete itself after about 30 minutes or so, also if you restart the file will also disappear.

This is very frustrating when you are doing things that require the deletion of exe files often.

The file doesn’t work with any kind of logic, once it’s locked it will be unable to be deleted until Windows (I’m assuming it’s Windows, or whatever causes the problem in the first place) decides to delete it.

It seems that the action of attempting to delete the file in the first place is what gives it these permission-excluding superpowers, before the attempted deletion the file will act correctly, opening and closing when you want, renaming and copying as you please, obviously with no indication of what it will do if you try to delete it.

This happens on the desktop, I really haven’t experienced it anywhere else, it may also occur in the user folder but I haven’t checked.

Running as the administrator, either by opening explorer as an administrator or by enabling the administrator account and then logging in with it will give sufficient permissions to delete this file.

This is unlike any permissions issue i have ever come across on any operating system, every file is deletable, even if you have to go as the root or admin account, this file however disobeys every possible windows based and 3rd party command thrown at it.

There are no disk errors, at least none found by chkdisk, restarting and running /r on my main drive is a little counter productive since as soon as I reboot the file will be gone so there will be no file issue to be found, for the record though, I have, no issues.

This is not the same as the issues people have in Vista and Windows 7 where folders can’t be deleted sometimes, as they can be deleted simply by taking ownership of them, or even by deleting the files in the folder individually.

I have submitted a bug report.

Software I have installed and have been run:

MS Visual Studio
RealVNC
iTunes
Quicktime
Firefox
Battlefield 2
Adobe Digital Editions
TextPad
7-Zip
Foxit Reader
Avira Premium Security Suite
VideoLAN
TortoiseSVN
Windows Live, :Just the messenger
CCleaner

Most importantly, I have formatted and reinstalled Windows 7 as previously I had upgraded from Vista and there seemed to be a possible link between upgrading and getting permission issues but now I’m not so sure.

If anybody has any information on this issue please comment below, does it happen to you? Do you have a remedy that works for you? Does it happen when you have performed a full install or an upgrade from either Vista or a previous build (!important!)? Do you have any of the same software installed as me? I’m taking particular interest in CCleaner and Avira here.

Published by

TechGremlin

Owner and main content writer.

91 thoughts on “Windows 7 – Can’t delete exe files on Desktop”

  1. I had the same thoughts on the problem, I’d say they picked it up during internal testing but we probably won’t know for sure until an RC comes out.

    I’m still waiting to put Windows 7 back on my main pc but so far my laptop still has no problems.

  2. So, I am not alone then.

    I often have this problem – do a build in VS 2008 an debug. End, and then I cannot rebuild as the file is locked. It seems to go away after some undetermined period of time, but its an enforced break in the code-test-repeat cycle which is very annoying.

    I had the problem, repeatable every time, which came when I was installing the Windows 7 SDK. A prereq MSI was being extracted, run, and then deleted – or, at least the delete was tried. Every single time, the temp MSI could not be deleted and the larger install failed. I actually would have to boot in to Ubuntu to delete the file, then back to 7 again.

    Highly frustrating. While I also run CCleaner, I had always assumed that it was something to do with protecting me form myself, as the issue is only with executable files. I figured Defender was holding the file or something. Ive given up trying to guess on it, ill just be glad when the problem goes away.

  3. It’s great news for people being able to get this fixed in build 7068, I have not had this problem since using this build.

  4. CCleaner 2.18.878 has just come out, is that what you are using? I’m about to test it out on 7077 x64 now.

  5. With all due respect, I think everyone should stop relating this error to CCleaner. People are having issues with this without CCleaner and has something to do with deleting a file (that seems to take 30min or more) to do so.. but during that time, it marks the file as Private or some inaccessible state.

  6. I agree, the problem is no longer caused by CCleaner (if it was in the first place) in any tests I have tried in the past 2 builds.

    Does anybody have any steps they follow that causes this problem to start? even intermittently?

    There are quite a few little file system anomalies other than this, for example the issue where you delete a file and it stays where it is for a while before disappearing as it should. Also the problem that seems to be closer to this where you can’t delete a folder unless you remove the files inside it.

  7. In my case, I’m debugging a C# application. VS2005/VS2008 for WinForms and VS2008/Blend3 for WPF. At any point when any of these executables are loaded (double clicking, or invoked via IDE’s during debugging), the problem is in it’s “initial” state. As long as you don’t try to delete the file, you’re okay (that’s why I say initial). However, if you try to delete it, the problem is intermittently there… and especially with development where a rebuild attempts to delete the file, thats when the issue is first noticed.
    It does seem that the Win7 is in the middle of deleting the file (i.e. marked it for deletion) but doesn’t actually successfully complete it (until much later). Until that time, the file is marked Private and cannot be deleted (because technically it’s already being deleted). Consequently, parent folder(s) also cannot be deleted. I’ve read reports that if you wait it out, it will eventually be deleted. But personally, an immediate restart also “fixes” the problem. However, on a restart, it seems the pending deletion of the file is ‘cancelled’ because the file is still there (after the restart)… but is no longer in the Private state, which means you can again delete it (but since it hasn’t been loaded, the delete is successful).

    I wish I could get a hold of all these other builds that are reporting the bug to be fixed.

  8. For Files:

    takeown /f file_name /d y
    icacls file_name /grant administrators:F

    For Directories (will perform action recursively):

    takeown /f directory_name /r /d y
    icacls directory_name /grant administrators:F /t

    Above syntaxes will grant full permission to administrator group hence you must be a part of administrator group to take advantage of above command.

    BTW I’m using Build 7000 x64, if you have any questions email me at [email protected]

    Sorry for the multiple posts, but I ran this from the command line on my Desktop folder and haven’t had the problem since.

    Found this online:

    Add this to a text file and name it own.reg

    [HKEY_CLASSES_ROOT\*\shell\runas]
    @=”Take Ownership”
    “NoWorkingDirectory”=””

    [HKEY_CLASSES_ROOT\*\shell\runas\command]
    @=”cmd.exe /c takeown /f \”%1\” && icacls \”%1\” /grant administrators:F”
    “IsolatedCommand”=”cmd.exe /c takeown /f \”%1\” && icacls \”%1\” /grant administrators:F”

    [HKEY_CLASSES_ROOT\Directory\shell\runas]
    @=”Take Ownership”
    “NoWorkingDirectory”=””

    [HKEY_CLASSES_ROOT\Directory\shell\runas\command]
    @=”cmd.exe /c takeown /f \”%1\” /r /d y && icacls \”%1\” /grant administrators:F /t”
    “IsolatedCommand”=”cmd.exe /c takeown /f \”%1\” /r /d y && icacls \”%1\” /grant administrators:F /t”

    Then double click. Now you can right click on files or folders to take ownership EASILY!

  9. @Daniel
    I have already tried using the /takeown command (and I assume most everyone that has the problem has also done so) and it yields the very same error as if doing it from GUI (as one would expect since it would inevitably call the same Win API). The problem is not specifically with ownership. The problem is due to the fact the file is in the middle of being deleted (whatever that really means), so any file operations performed on the file (taking ownership, another attempt at deletion, etc) fails.

    If you want more information on the error, you can read up on this post:
    http://social.technet.microsoft.com/Forums/en-US/w7itprogeneral/thread/4301c7d1-88ba-4c94-88c2-e5f1850f062f/

  10. I condensed your comments into one Daniel, Jayson is right as this specific problem isn’t technically a permissions problem as permissions don’t have a chance to come into effect.

    I do however encourage people suffering from a permissions error to follow Daniel’s instructions, also if you’re unsure if you’re suffering from this issue or if you are just suffering from a permissions issue then give it a go first.

  11. Has this issue been resolved in later builds?

    Believe it or not, I had the exact same issue with Vista!

  12. I haven’t experienced the issue in the latest public release (7100 Release Candidate), anyone who is running the Beta build is encouraged to upgrade to it.

    I haven’t heard of it happening in Vista before, but I assume it’s possible in certain situations.

  13. I just had this happen to me on RC 7100… All’s I did was enable HomeUsers full access to the folder… For some reason it wasn’t seeing me access the folder as the username I am under… Setting that let me take the Read-Only attribute off the folder and files and I could delete the files finally.

  14. I’m planning on upgrading to RC next week… I’ll report what I find, as well. I’m hopeful.

  15. I had the same problem with W7 beta and VS2008 and I was using CCleaner, too. Now I’ve moved back to XP, so no idea about the RC.

Leave a Reply

Your email address will not be published. Required fields are marked *