tags:

views:

5615

answers:

5

I installed my application in Windows 7 and as part of the installation, it installs some text files. Now, if I open the text file in notepad and try to save it, I get an "Access denied" error. I'm logged in as administrator on the machine and the file is not marked read only and security permissions seem to be fine.

However, I could delete or rename the file without any problem and I could create a new file with the same name/location using notepad and the save works fine.

I understand it has something to do with UAC. I'm wondering what UAC does in order to block access to the file. Our application is not installed in Program files folder as I believe UAC restrict any changes to files in Program Files folder

Can anyone throw light on what is going on.

regards G

+1  A: 

With UAC, just because you're logged in as a user with administrator privileges does not mean a program actually runs with them. The program has to either request privilege elevation (which gives the "Do you want to allow this program to _" UAC pop-up) or explicitly be run as administrator (right-click on the program/shortcut and choose Run as Administrator).

By default most areas of the drive outside of the standard "user files" (a.k.a. My Documents & co.) are restricted to administrator-only access, but the folder permissions can be changed to add access for a particular user if desired.

Amber
As I stated in my original question, I'm able to delete/rename the file that gave access denied error when saving through notepad. Also, I'm able to create new files in the same location where I get access denied error.My guess when our application gets installed using Installshield, windows 7 treats all the files that were deployed a part of the installation and thereby preventing access. Really wondering how UAC prevents access to only certain files and how it keeps track of whether the files were deployed by installation program
Ganesh
There may be different levels of access in play with regards to Windows Explorer processes (where you'd be doing the renaming/moving) as opposed to non-system applications (such as Notepad).
Amber
This answer suggests a tactic that may be useful: use 'Run as Administrator' to open notepad, then edit and save the file.
grossvogel
A: 

You will find that saving files almost anywhere except the "my documents" area for the user will be restricted, this includes saving to other drives on the system etc.

If you check the permissions for the directory you are trying to write to, all you have to do is expressely give the user permission. Otherwise only the admins have permission, which requires UAC approval from the user to get the admin token.

Myforwik
A: 

You normally get "Access Denied" error when the file is in use. UAC could not be an issue here. Check out if the file is in use by anyother process.

You can use tools like Process Explorer from sysinternals to do that.

Jagannath
The fileis not in use for sure, because I'm able to rename it/delete it. Just saving from the notepad or any editor gives me this error.
Ganesh
A: 

Thank you !!!!! Run as admin and open the file. Thanks allot!!!

Tom
A: 

You have to right click the file and select properties. THen open the security tab and you can see different accounts with differet privelages. Click USERS and it should highlight. The box under it should have a bunch of check marks that indicate what this user can do. Click Full Control. Apply and Okay. Then you can save!!!

Connor

related questions