51432

Self-Updating .NET client application which needs to write in the Program File folder

<strong>Similar to:</strong> Request Windows Vista UAC elevation if path is protected?

I have a .NET Client Application installed in c:\Program Files (Windows Vista). This application should update itself, but it doesn't because of permission issues. The auto-updater should simply replace a couple of assemblies, but they are all located under c:\Program File and the application throws the following exception:

System.UnauthorizedAccessException: Access to the path 'C:\Program Files...' is denied.

I have no control on where the application could be installed and the permission. Is there any workaround for this? Is it possible to request the Administrator rights for a couple of seconds? Is it possible to pop a UAC window? I am pretty sure that there a workaround... Otherwise, how Firefox would be able to update itself?

Thanks in advance for the help and ideas!

Answer1:

Could you use a Click Once deployment method? We use this for an internal application and users have no problems with permissions when we publish a new version. They are prompted to install the update when they launch the app (if a new version exists) and it installs without a hitch.

Answer2:

You can't elevate a process's permissions halfway through, but you can start up another separate process with higher permissions that can do the work for you.

Get your main application to put all the files / installation details into a low-permission temporary location. When you're ready, start up a smaller application whose only job is to copy over those files to the Program Files directory (and maybe restart your main application with the new updates). Mark that application as requiring the needed permission to copy to the Program Files directory or write to the registry (or whatever else is needed).

Recommend

  • Combine set of conditions in data.table to extract value using binary search
  • publishing a typescript library on npm: exported symbols, modules
  • How can i display date in a 1 by 1 array when i use datestr?
  • Can you force MonoTouch to include an unreferenced assembly in its static compilation?
  • finding values in pandas series - Python3
  • Xpath how to get element by index AND attribute
  • pandas mix position and label indexing without chaining
  • Compare Pandas dataframes and add column
  • How to run xUnit 2.1.0-beta-* for DNX projects with ReSharper
  • Display Custom Marker in Google Maps Using Relative File Path [duplicate]
  • Find code that depends on .NET 3.5 SP1
  • C# where to add a method
  • LyX — Title, Abstract, Keywords Missing When Using Elsevier Class in View
  • Could not install package 'Microsoft.Owin.Security 2.0.1'
  • IIS 7.5 404 Error for .PDF files
  • Dependency Injection and Code Obfuscation
  • how to load css classes from my own project specfic css in Sitecore's RAD editor?
  • How to remove comma or any characters from Python dataframe column name
  • PHP in userdir not working
  • Autohotkey script running program with command line arguments
  • auth.provider is not set to 'password' when user signs-in with email and password
  • php is_file always return false
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • javascript inside java/jsp code
  • Javascript Callbacks with Object constructor
  • Validaiting emails with Net.Mail MailAddress
  • ILMerge & Keep Assembly Name
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Weird JavaScript statement, what does it mean?
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Apache 2.4 - remove | delete | uninstall
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Android Studio and gradle
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Revoking OAuth Access Token Results in 404 Not Found
  • Proper folder structure for lots of source files
  • Benchmarking RAM performance - UWP and C#
  • How does Linux kernel interrupt the application?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • How can i traverse a binary tree from right to left in java?