Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi there,

I have developed an application in vb.net 2008. It runs well except on windows 7.
The problem I face is when I am running my application on windows 7 it throws an error saying access denied. If I right click on exe and then click on run as an administrator it runs fine.

Can anyone please tell me it this is a windows' security problem or my deployment problem?

Please give me the solution too.

Thanks in advance...

[EDIT]
After seeing many blogs and forums I found that I need to change app.manifest
I did the following changes in app.manifest

from
<requestedexecutionlevel level="asInvoker" uiaccess="false" />


to
<requestedexecutionlevel level="requireAdministrator" uiaccess="false" />


and I got this error
Error 1 ClickOnce does not support the request execution level 'requireAdministrator'

Any help please.....
Posted
Updated 20-Apr-11 12:12pm
v2

You should check, in your application, what is the resource requiring administrator privileges (for instance access to some registry keys) and either use another resource (for instance keys in the HKEY_CURRENT_USER tree insted of keys in the HKEY_LOCAL_MACHINE one) or demand privilege elevation (see for instance Making Your Application UAC Aware[^].
 
Share this answer
 
Comments
CodingLover 20-Apr-11 7:34am    
Thanks for sharing the link Pallini. I'm searching that in the past.
hiren soni 20-Apr-11 7:40am    
This is the exact problem I got. I am trying to read/write path from program files.
What should I do now?
What exactly is your application doing, is it trying to read data from some path? UAC will protect certain paths and you'll see the 'Access is Denied' message

Have a look at the call stack....where is the error occurring. Is it trying to read \ write data?

This thread on MSDN[^] shows some possible solutions
 
Share this answer
 
Without knowing what your application does, it is impossible to give an accurate answer.

The problem is certainly related to permissions in some way but exactly how is not ascertainable from your question.

Does the application try to write to the Program Files Folder?
Does it try to modify the Registry?

What does it do?
 
Share this answer
 
The most common problem that causes this is writing data to a folder under Program Files. With Vista and Windows 7, program Files is now ReadOnly to normal users to protect application code files.

The solution is quite simple. Write your data to a folder that is more appropriate. Program Files should never be used to store program data.

Which folder is appropriate depends on what this data is for and who needs it. Is it going to be shared among all users on the machine or is it different data for each user? Is it going to be portable, meaning should it only be on that one machine, or should the data follow the users profile from machine to machine (IF and only if the environment supports roaming profiles!)?

Look at the documentation for Environment.GetFolderPath for how to get the path to various folder locations. Look at the documentation on enumeration members for SpecialFolders for descriptions of what each of these folders is meant for.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900