Windows 7 access denied to executables.. by what?

Posted by stijn on Super User See other posts from Super User or by stijn
Published on 2011-11-24T10:25:21Z Indexed on 2011/11/26 17:57 UTC
Read the original article Hit count: 259

Ever since I started using Windows 7 this problem has been bothering me. From time to time I see similar questions popping up on misc forums, but never did I see an answer. Here are two scenarios that nearly always reproduce it:

the explorer way

  • with explorer, navigate to a directory containing at least one exe file
  • go one directory up immediately
  • delete the directory just navigated to
  • yields Folder Acces Denied dialog stating You need permission to perform this action You require permission from Administrators to make changes to this folder, with the buttons try Again and Cancel
  • hitting Try Again never works immediately. Waiting a minute or so and then clickig it again does work

note: if in step 2 and waiting a minute or more before going up one directory, the problem does not occur and the folder can be deleted

the visual studio way

  • build a project producing an exe file
  • run the executable then close it
  • immediately build the project again (by changing a single character in a source file for example)
  • yields fatal error LNK1168: cannot open /path/to/the.exe for writing

note: if in step 2 and waiting a minute or more before building again, the problem does not occur

some specs

  • happens both on Windows 7 32 and 64 bit, with VS2008/2010/2011
  • happens on 3 different machines
  • I do not have a virusscanner of any kind
  • I do have a bunch of services disabled, but nothing that prevents Windows from running normally, UAC is disabled as well
  • happens on any type of disc
  • I always use a user account that is in the Administrators group

Obviously both scenarios are very similar and extremely reproducable. So I figured some process must have the file open for some reason, and release it again later. However, using systinternal's

handle -a

the exe file in question never shows up. (that is the correct way to use handle, right?) So while explorer/VS are reporting they cannot access the file, handle.exe says it's not in use anywhere. This leaves me rather clueless, so I'm wondering if someone can come up with a solution: why does this happen, and how to solve it?

© Super User or respective owner

Related posts about windows-7

Related posts about visual-studio