Click here to Skip to main content
15,908,768 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
This has probably been asked before and also been answered but I don't know how to search for it so I ask it by myself.

When you create a software you can install it or put it directly under C:\ or why not a subfolder you have created like C:\mysoftware\ and it works fine.
But when you install it (I have a bunch of free installer-software) under the program files folder the software you have created is suddenly denied to read or write files within its own folder, but works well in a folder like C:\mysoftware\.

So to my question, how do I give the software the administrator rights (or raise to that state) so it can be installed under Program Files folder and work properly?

I'm searching for codes here or something similiar though it works by giving the software the administrator rights by right clicking on it (which is not the solution I want).
Posted

AFAIK. this cannot be controlled by code.
You need to specifically request an administrator to give you rights to install a program in a folder, or he can install the program for you.
 
Share this answer
 
Hi,

Since the release of Vista access to the program files folder is restricted. If you really, really need to allow your application to write files in the program files folder, you could change the security settings on the folder. The best solution would be to change the software code so that it write files somewhere else... but assuming you can't do that, here is how to do change the security settings:

icacls "c:\Program Files\my program\*" /grant theUserName:(F)


This batch has to be ran in an elevated state. (ie during installation, or by running CMD as an administrator).

Once again this is bad practice, and you should only do this if you can't find an alternative.

Read this article for detailed reference:

http://technet.microsoft.com/en-us/library/cc753525(WS.10).aspx[^]

Valery
 
Share this answer
 
Comments
[no name] 29-May-11 8:22am    
Thank you for your answer (and all others).
There is no problems by putting it under user folder and its subfolder, i just have to change the code a little.
The most important thing is that it should be alowed to read the files within its own folder and I just tested that and it works (there are plenty xml files I work with so that's great).
thatraja 29-May-11 11:13am    
It's a good link man...I have bookmarked your answer, Get my 5!
You can't do it from with the program. The easiest way is to right-click the exe file in question, and select Properties. In the subsequent dialog box, click he Compatibility tab. There, you will find an option to run the app as administrator. You can also cause the program to prompt the user for admin access, and there are a few ways to go about it. Google is your friend.
 
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