Menu

#399 Set uninstallers RequestExecutionLevel at runtime

open
nobody
None
5
2014-12-16
2007-11-08
Anders
No

This is mostly related to the UAC plugin since the installers execution level must be set to "user".

Forum thread: http://forums.winamp.com/showthread.php?s=&threadid=280330

The problem is that when the uninstaller (UAC plugin) calls ShellExecuteEx with the runas verb in un.OnInit, the Vista UAC displays a "weird" name in its UI since NSIS already has copied the uninstaller to $temp and this is the exe that is actually running

It is currently possible to get around this by making another copy, but the process tree becomes quite large for what should be just one process (or two when counting the elevated "real" process)

$temp\~nsu.tmp\Au_.exe
+ $pluginsdir\UninstallerName.exe (my copy to fix name)
++ $pluginsdir\UninstallerName.exe (elevated from runas)

So my request is to add an instruction that will set the RequestExecutionLevel used by the uninstaller (could be called any number of times before WriteUninstaller)

You probably don't need any xml handling for this, just store the offset in the manifest for the "level=" part, BUT the original manifest needs to become a couple of bytes larger so there is space for a possible admin>asInvoker change from installer to uninstaller (<requestedExecutionLevel level="user" EXTRA SPACE HERE uiAccess="false"/>)
For the UAC plugin, this is not needed, you would only ever go from user>admin, but might be nice for completeness.
(The reason the uac plugin does not do this is ofcourse the CRC, I'm guessing this would be easy to do for nsis itself, another bonus would be that Vista would display the shield icon overlay, there is no way for the UAC plugin itself to trigger that)

If the installer does not specify RequestedExecutionLevel it does not make sense for this instruction to work at all

Discussion

  • Amir Szekely

    Amir Szekely - 2007-11-08

    Logged In: YES
    user_id=584402
    Originator: NO

    Would be a nice feature and it could be accomplished by modifying the icon switching mechanism, but I don't see how it'd help getting rid of one more process? Do you want to set it to "user" and then have the UAC plug-in do the elevation with a good process name?

     
  • Nobody/Anonymous

    Logged In: NO

    No, I want to mark the "original" uninstaller as RequestExecutionLevel admin (so elevation will happen before the actual copy trick) but it needs to happen at runtime for installers that support both single and all user installs (single installer would be marked as user, all user as admin)

     
  • Nobody/Anonymous

    Logged In: NO

    Maybe the uninstaller could just use the original uninstaller name for the temp copy. It could use a temp dir (like Pluginsdir) and copy the file with the original name there (no problem because temp dir is empty).

    This could make debugging a bit simpler, too.

     
  • Amir Szekely

    Amir Szekely - 2008-05-02

    Logged In: YES
    user_id=584402
    Originator: NO

    The problem with anonymous' suggestion is that the uniform name has a reason. That copy isn't immediately deleted but only after reboot and so a lot of copies of a lot of uninstallers could gather around in the temporary directory. By sticking to a uniform name, other uninstallers could clean up after each other and multiple uninstallers with the same name could still run at the same time.

     
  • Amir Szekely

    Amir Szekely - 2008-05-02

    Logged In: YES
    user_id=584402
    Originator: NO

    And as for the original request, it won't be that easy. NSIS calculates the CRC in build time and only gives the installer offsets to modify in the uninstaller which do not include the CRC.

     
  • Sebastian Walderich

    I am also interested in this feature. Is there any progress on the ticket, or a workaround? I have an installer with "user" privileges but would like to raise the uninstaller to "admin", if the installer was manually given administrator privileges.

     
    • Anders

      Anders - 2015-01-25

      Are you changing the way your installer works if the user is admin? If not, why would the uninstaller need to elevate?

      There are many ways to handle this, you could:

      • Generate a extra uninstaller on your machine similar to how you would sign a uninstaller.

      • Just detect it and ask the user to manually elevate.

      • Create a small wrapper exe in NSIS that restarts your uninstaller elevated

      • Use RequestExecutionLevel Highest to always force admins to elevate when installing and uninstalling

       

Log in to post a comment.

MongoDB Logo MongoDB