Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Install updates without elevation, automatically at user logon

Tue Jul 13, 2021 12:33 pm

Hello,


Sometimes, installing updates without elevation can be challenging, thus adding here a samples project to implement this could be of great help.

Useful resources:
The updates are installed silently, the check for updates is happening at user logon, the check being triggered by a scheduled task configured to run under the System account. This way, the application can be updated under any user account from the machine, it doesn't matter if the user has admin privileges or not.

Also, there is another task that is being triggered hourly, indefinitely. So, multiple scenario can be implemented just by adding multiple tasks with different startup type.


Here's what the .zip archive contains:

content.PNG
content.PNG (18.45KiB)Viewed 237634 times

where:
  • SampleWinFormApp - is tthe VS project for the demo WinForm app
  • Updates-SetupFiles - the output location of the updates file. This file is used by the updater to determine if an update is available or not
  • v1 - where the project file and V1.0.0 of the installer is located.
  • v2 - where the project file and V2.0.0 of the installer is located.
  • activate logging.reg - Add these registry in case debugging is needed e.g. in case the installation fails to be installed.
  • Updates.aip - project file that builds the updates file

How to test the sample app

To test the sample app, just install the Demo App.exe from the v1 folder: .\v1\Demo App-SetupFiles.

After the installation, there should be 2 shortcuts created on the desktop:
  • 1.0.0 - Check for updates Demo App shortcut, this is a shortcut to the Updater so that you can even manually check for updates. Also, it contains version in its name to be easier to track installation of the updates
  • Sample WinForm App which is a shortcut to the sample app
demoAPp.PNG
demoAPp.PNG (114.96KiB)Viewed 237634 times

How to test updates installation?
To test the updates installation, just open the Task Scheduler and find any of the below tasks that can trigger the Updater to check for updates and automatically install them in case any update is found.

Basically, just need to pass the command line for the updater:

Code: Select all

/silentall -nogui -nofreqcheck
taskScheduler.PNG
taskScheduler.PNG (28.98KiB)Viewed 237634 times


The updates should be installed automatically, no UI of the Updater or from the installer should be displayed during upgrade process. Also, the updates should be installed without any UAC prompt.


Some scenarios that should be covered
A common case that could happen is to have the application running. To be able to install updates, the application should not be running. The V2.0.0 will automatically close the application through a detect and stop running process approach. For details, check the How to detect or stop a process article.


How to debug falling installation

Double click the activate logging.reg file and answer "Yes" to the confirmation prompt.

Code: Select all

REGEDIT4

[HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Installer]
"Logging"="voicewarmup"
"Debug"=dword:00000007
The .LOG file will be created in the currently logged on user's Temp folder and will have a name in the following format: "MSI*.LOG". Check the How Do I Read a Windows Installer Verbose Log File article that explains the main concepts of how to debug a verbose log file created by the Windows Installer.


The sample project is attached to this thread, so if you are interested to take a look directly at my project, you are more than welcome to download the project file.
Download sample project

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Sample Projects”