Admin elevation is not handed over to updated version

I have a situation where I select RunAs Administrator, but this elevation is not handed over to the updated version of the program.

Background:* The software is one file: Program.exe* Program.exe is placed in c:\FolderX\* wyUpdate.exe and client.wyc is placed in c:\FolderX\ as well. (the point is that this is not a "local user folder")

Reproduction of error:

0. Program is version 11. Run c:\\FolderX\program.exe (right click, run as administrator).2. In started program: Click "Check for updates". A new update is downloaded and Program.exe is restarted and updated, without me having to give the application permission via UAC. Program is now version 2.3. A new version, 3, is published to the update server4. I click "check for updates" in my application. ---> Problem: A new update is found, Program.exe is closed, but the UAC window pops up, and I need to actively allow the program to update.

Problem: The admin elevation is not handed over to the re-installed version of the app in step 2.

Am I doing something wrong? Why not restart the application in step 2 with the highest available privileges? In my mind, that is the behavior I'm supposed to get when I actively choses to Run the software as administrator in the first place.

I want to be able to set the application in a "fire and forget" mode, where I start elevated, and let the application to auto update itself, forever. Is there a way to accomplish this (except placing the application in a "user profile folder"?.

Am I doing something wrong? Why not restart the application in step 2 with the highest available privileges? In my mind, that is the behavior I'm supposed to get when I actively choses to Run the software as administrator in the first place.

You're not doing anything wrong, and this is by design. wyUpdate restarts your app as normal elevation. Why? Because very few apps should be running as elevated. (Also, "normal" apps experience problems when running elevated. For instance, drag & drop between explorer fails to work).

I want to be able to set the application in a "fire and forget" mode, where I start elevated, and let the application to auto update itself, forever. Is there a way to accomplish this (except placing the application in a "user profile folder"?.

Other than putting wyUpdate in the user profile folder? Yes. Either install your updates using a dummy Windows Service that calls wyUpdate (see: this or this). Or give non-elevated users permission to modify your files and wyUpdate won't need elevation.

Thanks for the quick reply.

I understand that running the application in an elevated mode isn't optimal.

For anyone that is interested, this was my final solution:

1. Download the source of wyUpdate to find out in what situations you where triggering UAC (which turned out to be either running from a user profile location, or having full modification rights to the folder**)2. Copied that code to my application3. Have the logic from 1 as a pre-condition, and if this triggers, inform the user to either move the application to a user profile location, or give full modification rights to the current folder.

** You _really_ should document this behavior somwhere in the help section.

You're absolutely right, we'll make documentation that clears this up.