1

As a Notepad++ fan, I have seen that when there is a new update available, the following happens:

  • Notepad++ tells you that there is an update
  • When you click "Okay, let's update", it connects to the server
  • it downloads the update file
  • Notepad++ is closed and update file starts to run
  • UAC asks you if you want to run the file
  • When yes, it installs the update
  • You are asked to re-run Notepad++

I want to build this functionality in my .NET desktop application. What I don't know is after the file is downloaded:

  • how will my application tell the OS to run the update file?
  • my application does not have permissions to install files on the computer. How will it bypass that?
  • how will my application gets closed because during the update process, current application needs to be changed?
Farhan
  • 2,535
  • 4
  • 32
  • 54
  • 1
    These are three questions, I think too broad for SO - did you do any research? First google hit for "c# self updating program" was https://stackoverflow.com/questions/12787761/how-to-automatically-update-an-application-without-clickonce - and that one links to more similar questions. – C.Evenhuis Nov 09 '17 at 21:51

1 Answers1

2

how will my application tell the OS to run the update file?

Your c# application can easily call other processes by using the Process.Start method (present in System.Diagnostics ) and even control it if you want.

my application does not have permissions to install files on the computer. How will it bypass that?

The updater is a separate process, which can ask itself Administrator permissions (by invoking UAC dialog).

A c# application can easily ask for Administrator permissions by implementing a proper app.manifest file:

On Visual studio you can do this by selecting "Project" -> "Add new item" -> Application manifest, open it and change this line

 <requestedExecutionLevel level="asInvoker" uiAccess="false" />

with this

 <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

how will my application gets closed because during the update process, current application needs to be changed?

Your updater application can close your main process when it's done or your main process can close itself when the updater have finished (by using some sort of IPC).

An other alternative is to just launch the updater process from your main application and then immediately close your main application.

fruggiero
  • 943
  • 12
  • 20