views:

2313

answers:

3

I have a small program that is installed in a custom folder in the program files, but when I tried to read or write to files that are needed to operate, the program raises an Access Denied Exeption. How can I elevte the program, with the user's permission of course.

+1  A: 

I guess you're running under Vista? In Vista I don't think you're allowed to read/write to files under Program Files, you should put your data files in Documents and Settings instead.

Ulf Lindback
No it's in XP but I intend to run it in Vista too
Jonathan Camilleri
You can read files in the Program Files folder, just not write to them unless you have elevated privs.
Scott Dorman
How can I get the elevated privs?
Jonathan Camilleri
A: 

You can do everything you need using the ClickOnce APIs. If you have multiple parts (e.g., more than one EXE) then you need to include them in your package.

The only scenario not supported (by ClickOnce) as far as I know are authenticating proxies.

Philipp Schmid
A: 

ClickOnce supports installing any number of executable files, although you may need to manually include them in the manifest definitions.

To be correct and play well within the restrictions of least user access (LUA) and user access controls (UAC) your application should not write to the program files folder at all except during installation. If you must do this, you should include a manifest file that indicates your application requires elevated privileges to run. (If you are running on Vista you can also set the compatability mode.)

Scott Dorman