locked
Online update and UAC RRS feed

  • Question

  • Hi

    We are trying to write an automatic updater that is compatible with the Vista UAC.

    I understand that the installation of the updates should require elevated privileges, but we obviously cannot have the user entering the administrator password every time they want to use the software, regardless of whether there are any updates to be installed.

    How would it be possible to make the application only request elevated privileges when an update is going to be installed? 

    It doesn't seem to be possible to simply launch an external application (ie, an installer which generates a UAC prompt) programmatically using shell execute - it returns error 740, "privileged escalation required" and we can't find any way around this.

    Thanks
    Wednesday, March 14, 2007 12:24 PM

Answers

  • Hi,

    Yes, the solution David is talking about, exists in the ProcessStartInfo Class.
    And can be implemented like this:

    C# code:

    ProcessStartInfo proc = new ProcessStartInfo();
    proc.UseShellExecute = true;
    proc.FileName = "";
    proc.WorkingDirectory = @"";
    proc.Verb = "runas";

    Process.Start(proc);


    I hope this helps...

    I also, hope that this thread is solved so we can close it and continue...

    Have a nice day...

    Best regards,
    Fisnik


    Coder24.com
    Sunday, October 11, 2009 3:16 PM
  •  mcprospect wrote:


    It doesn't seem to be possible to simply launch an external application (ie, an installer which generates a UAC prompt) programmatically using shell execute - it returns error 740, "privileged escalation required" and we can't find any way around this.

    You need to supply the "runas" verb to ShellExecute in order to display a UAC prompt. You can find an example at http://www.codeproject.com/useritems/VistaElevator.asp?df=100&forumid=368223&exp=0&select=1922619

    More generally, if you author signed MSI based installers with the appropriate upgrade information you can take advantage of the fact that limited users can patch them with having to elevate, as that will be handled automatically by the Windows Installer service. See http://msdn2.microsoft.com/en-us/library/aa372388.aspx for details.

    Wednesday, March 14, 2007 12:38 PM
  • ShellExecute on a executable requiring elevation should result in UAC prompt, runas verb or not - coming back with 740 sounds wrong, from ShellExecute.  CreateProcess will fail with that, though.  Have you modified any of the UAC policies?  What sort of user are you running as when you're seeing this?

    As far as your updater, you might consider this setup:

    Write an exe, manifested "asInvoker" to do your update checking.  If you find out you need to actually do updates, ShellExecute another executable (manifested "requireAdministrator") to do the work.  If no updates are necessary, no UAC prompt.

    Or explore your options with MSI.

    Thursday, March 15, 2007 12:01 AM

All replies

  •  mcprospect wrote:


    It doesn't seem to be possible to simply launch an external application (ie, an installer which generates a UAC prompt) programmatically using shell execute - it returns error 740, "privileged escalation required" and we can't find any way around this.

    You need to supply the "runas" verb to ShellExecute in order to display a UAC prompt. You can find an example at http://www.codeproject.com/useritems/VistaElevator.asp?df=100&forumid=368223&exp=0&select=1922619

    More generally, if you author signed MSI based installers with the appropriate upgrade information you can take advantage of the fact that limited users can patch them with having to elevate, as that will be handled automatically by the Windows Installer service. See http://msdn2.microsoft.com/en-us/library/aa372388.aspx for details.

    Wednesday, March 14, 2007 12:38 PM
  • ShellExecute on a executable requiring elevation should result in UAC prompt, runas verb or not - coming back with 740 sounds wrong, from ShellExecute.  CreateProcess will fail with that, though.  Have you modified any of the UAC policies?  What sort of user are you running as when you're seeing this?

    As far as your updater, you might consider this setup:

    Write an exe, manifested "asInvoker" to do your update checking.  If you find out you need to actually do updates, ShellExecute another executable (manifested "requireAdministrator") to do the work.  If no updates are necessary, no UAC prompt.

    Or explore your options with MSI.

    Thursday, March 15, 2007 12:01 AM
  • Hi,

    Yes, the solution David is talking about, exists in the ProcessStartInfo Class.
    And can be implemented like this:

    C# code:

    ProcessStartInfo proc = new ProcessStartInfo();
    proc.UseShellExecute = true;
    proc.FileName = "";
    proc.WorkingDirectory = @"";
    proc.Verb = "runas";

    Process.Start(proc);


    I hope this helps...

    I also, hope that this thread is solved so we can close it and continue...

    Have a nice day...

    Best regards,
    Fisnik


    Coder24.com
    Sunday, October 11, 2009 3:16 PM
  • Hello mcprospect:

    How is the situation on your side?
    Is this thread solved or NOT?

    Please provide me with information!

    Have a nice day...

    Best regards,
    Fisnik
    Coder24.com
    Wednesday, October 21, 2009 6:30 PM