Menu

#1240 Example for signing uninstaller fails

3.0 Series
closed-accepted
nobody
None
5
2023-06-04
2020-02-27
Gene Thomas
No
  1. NSIS verion: v3.04
  2. error emssage:
    ...
    !define: "MUI_INSERT_NSISCONF"=""
    Changing directory to: "C:\Users\Owner\Documents\Projects\Remove Empty Folder"

    Processing script file: "1.nsi" (ACP)
    Inner invocation (1.nsi:2)
    OutFile: "C:\Users\Owner\AppData\Local\Temp\tempinstaller.exe"
    SetCompress: off
    Function: ".onInit"
    SetSilent: silent
    Error: command RequestExecutionLevel not valid in Function
    Error in script "1.nsi" on line 38 -- aborting creation process
    !makensis: returned 1, aborting
    Error in script "C:\Users\Owner\Documents\Projects\Remove Empty Folder\1.nsi" on line 11 -- aborting creation process

  3. Script: I am using the example .nsis script from https://nsis.sourceforge.io/Signing_an_Uninstaller
    execput that I have comented out the signing line one line 21: "!system "SIGNCODE <signing options=""> $%TEMP%\uninstaller.exe" = 0</signing>

Other attempts:

a. If I take out the "RequestExecutionLevel user" line windows open a dialog to ask for permission to install while compling the installer.

b. If I place "RequestExecutionLevel user" outside a function the installer has trouble writing
"Error ropening file for writing: \uninstaller.exe. ... [Abort] [Retry] [Ignore].

c. If I write:

!ifdef INNER
RequestExecutionLevel user ; don't write uninstaller with admin permissions and prevent invoking UAC
!else
RequestExecutionLevel admin ; don't write uninstaller with admin permissions and prevent invoking UAC
!endif

I get the same failure "Error ropening file for writing: \uninstaller.exe ...

d. If I change
File $%TEMP%\uninstaller.exe
to
File c:\temp\uninstaller.exe

and:
WriteUninstaller "$%TEMP%\uninstaller.exe"
to
WriteUninstaller "c:\temp\uninstaller.exe"

I get the same error when running the installer.

Please assist.

Discussion

  • Gene Thomas

    Gene Thomas - 2020-02-27

    Screen shot showing the installer failing to write \uninstaller.exe

     
  • Gene Thomas

    Gene Thomas - 2020-02-27

    Adding
    InstallDir "$PROGRAMFILES\Remove Empty Folder – Planet Earth Software"
    fixes this

     
  • Gene Thomas

    Gene Thomas - 2020-02-28

    So to fix the example wiki page about signing the unnistaller:

    1. Add
      InstallDir "$PROGRAMFILES\Test Install"

    2. remove :
      RequestExecutionLevel user ; don't write uninstaller with admin permissions and prevent invoking UAC
      as it does not work inside the "Function .onInit"

    3. added [not inside a function]:

    !ifdef INNER
    RequestExecutionLevel user ; don't write uninstaller with admin permissions and prevent invoking UAC
    !else
    RequestExecutionLevel admin ; don't write uninstaller with admin permissions and prevent invoking UAC
    !endif

    1. comment out the sign uninstaler line so this example works out of the box

    Run "C:\Program Files (x86)\Test Install\Uinstaller.exe" after installed as administartor to check that the uninstaller have been signed.

    I'm relativly new to NSIS so do not want to edit the wiki page. Attached is the .nsis script that works [when the signtool line is completed by the developer]

     
    • Anders

      Anders - 2020-03-03

      You probably don't want to dynamically change RequestExecutionLevel.

      Somebody had edited the wiki and placed RequestExecutionLevel in the wrong place.

       
  • Gene Thomas

    Gene Thomas - 2020-03-03

    My understanding is that the nsis run with /D INNER does not need to run a admin, if it is set like that it asks e user if it is ok to run as adminitarator which is not required.
    The actual installer does need to run as administartor or you won't be able to write to C:\Prorgam Files etc...
    My attach .nsi works.

     
  • Anders

    Anders - 2023-06-04
    • status: open --> closed-accepted
     

Log in to post a comment.

MongoDB Logo MongoDB