Windows Develop Bookmark and Share   
 index > Windows Forms General > UnauthorizedAccessException in Windows Vista
 

UnauthorizedAccessException in Windows Vista

Hi all!

I developed a self updating application (Windows Forms). When there is a new version, I have to copy it to the directory that it was previously installed.

If the application is installed in another directory outside "\Program Files", it is working well.

The problem is that if the application is installed in "\Program Files\Product", where I have an UnauthorizedAccessException when I start copying the new version (I am using File.Copy()). Is there a way to copy files to this directory?

Thank you,
Vanessa

vnihues72  Friday, July 18, 2008 9:52 PM
To install an upgrade your updater need to be running as admin. Use an application manifest to demand elevation. You can search Vista elevation manifests in Vista development forums for more information.
Sheng Jiang 蒋晟  Friday, July 18, 2008 10:32 PM
Your problem is not specific to Vista, it would fail on XP as well when the user is logged in with a non-admin account. At least Vista gives you the option of a UAC prompt but that would rather defeat the purpose of UAC. You'll need a service to get your .exe updated, MSI can do it. Or buy a commercial solution.

Please use this forum only to ask Windows Forms questions.
nobugz  Saturday, July 19, 2008 3:01 PM
To install an upgrade your updater need to be running as admin. Use an application manifest to demand elevation. You can search Vista elevation manifests in Vista development forums for more information.
Sheng Jiang 蒋晟  Friday, July 18, 2008 10:32 PM
Your problem is not specific to Vista, it would fail on XP as well when the user is logged in with a non-admin account. At least Vista gives you the option of a UAC prompt but that would rather defeat the purpose of UAC. You'll need a service to get your .exe updated, MSI can do it. Or buy a commercial solution.

Please use this forum only to ask Windows Forms questions.
nobugz  Saturday, July 19, 2008 3:01 PM

You can use google to search for other answers

Custom Search

More Threads

• ComboBox Column AutoCompleteMode = AutoCompleteMode.SuggestAppend Width Problem
• How can I find out which TabPage is active?
• Single Key Shortcut for Menuitems
• Multiple keys in hotkey?
• HashPasswordForStoringInConfigFile in windows app
• Isolated Storage
• Combobox items Adding!!
• form_load event of form is not fired when a form is selected from FormCollection and displayed using form.show() method
• Designing a Text Editor
• create Graphic frequency Equalizer