<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://nsis.sourceforge.io/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Signing_an_Uninstaller_externally</id>
	<title>Signing an Uninstaller externally - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://nsis.sourceforge.io/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Signing_an_Uninstaller_externally"/>
	<link rel="alternate" type="text/html" href="https://nsis.sourceforge.io/mediawiki/index.php?title=Signing_an_Uninstaller_externally&amp;action=history"/>
	<updated>2026-05-28T18:52:06Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://nsis.sourceforge.io/mediawiki/index.php?title=Signing_an_Uninstaller_externally&amp;diff=25984&amp;oldid=prev</id>
		<title>ChrFranke: First</title>
		<link rel="alternate" type="text/html" href="https://nsis.sourceforge.io/mediawiki/index.php?title=Signing_an_Uninstaller_externally&amp;diff=25984&amp;oldid=prev"/>
		<updated>2026-01-06T13:16:51Z</updated>

		<summary type="html">&lt;p&gt;First&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;NSIS v3.08 added support for &amp;lt;span style=&amp;quot;font-family: monospace, monospace;&amp;quot;&amp;gt;!uninstfinalize&amp;lt;/span&amp;gt;.&lt;br /&gt;
This command requires that a code signing tool could be run by makensis.&lt;br /&gt;
This is not always the case.&lt;br /&gt;
&lt;br /&gt;
If only an outer workflow for signing is available, first run makensis to create and export the uninstaller.&lt;br /&gt;
After signing the uninstaller, re-run makensis to create the installer using the already existing uninstaller.&lt;br /&gt;
&lt;br /&gt;
For a real world use case, please see the&lt;br /&gt;
[https://github.com/smartmontools/smartmontools/blob/970ef448f928ed38ff4b1622005b36ecdb699cac/src/os_win32/installer.nsi#L264 smartmontools installer]&lt;br /&gt;
and the related&lt;br /&gt;
[https://github.com/smartmontools/smartmontools/blob/4495f4d08238fb76452ae50295c0abf5c77e3f21/.github/workflows/signpath.yml#L40 signpath workflow].&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;highlight-nsis&amp;gt;&lt;br /&gt;
Name &amp;quot;Installer&amp;quot;&lt;br /&gt;
OutFile &amp;quot;install.exe&amp;quot;&lt;br /&gt;
RequestExecutionLevel user&lt;br /&gt;
InstallDir &amp;quot;$DESKTOP\nsis-test&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Section&lt;br /&gt;
  MessageBox MB_OK &amp;quot;Installing...&amp;quot;&lt;br /&gt;
  CreateDirectory &amp;quot;$INSTDIR&amp;quot;&lt;br /&gt;
  SetOutPath &amp;quot;$INSTDIR&amp;quot;&lt;br /&gt;
!ifdef IMPORT_UNINST&lt;br /&gt;
  ; Use file from &amp;#039;makensis -DEXPORT_UNINST&amp;#039;&lt;br /&gt;
  File &amp;quot;uninstall.exe&amp;quot;&lt;br /&gt;
!else&lt;br /&gt;
  WriteUninstaller &amp;quot;uninstall.exe&amp;quot;&lt;br /&gt;
!endif&lt;br /&gt;
SectionEnd&lt;br /&gt;
&lt;br /&gt;
!ifdef EXPORT_UNINST&lt;br /&gt;
  ; Copy file for &amp;#039;makensis -DIMPORT_UNINST&amp;#039;&lt;br /&gt;
  !uninstfinalize &amp;#039;echo copy /Y &amp;quot;%1&amp;quot; uninstall.exe&amp;amp;copy /Y &amp;quot;%1&amp;quot; uninstall.exe &amp;gt;nul&amp;#039;&lt;br /&gt;
!endif&lt;br /&gt;
&lt;br /&gt;
!ifndef IMPORT_UNINST ; Only if &amp;#039;WriteUninstaller&amp;#039; is used&lt;br /&gt;
Section &amp;quot;Uninstall&amp;quot;&lt;br /&gt;
  MessageBox MB_OK &amp;quot;Uninstalling...&amp;quot;&lt;br /&gt;
  call un.Uninstall&lt;br /&gt;
SectionEnd&lt;br /&gt;
&lt;br /&gt;
Function un.Uninstall&lt;br /&gt;
  Delete &amp;quot;$INSTDIR\uninstall.exe&amp;quot;&lt;br /&gt;
  RMDir &amp;quot;$INSTDIR&amp;quot;&lt;br /&gt;
FunctionEnd&lt;br /&gt;
!endif&lt;br /&gt;
&amp;lt;/highlight-nsis&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run:&lt;br /&gt;
&lt;br /&gt;
  makensis -DEXPORT_UNINST installer.nsi&lt;br /&gt;
  run_outer_signing_workflow_on uninstall.exe&lt;br /&gt;
  makensis -DIMPORT_UNINST installer.nsi&lt;br /&gt;
&lt;br /&gt;
The above uses Windows &amp;lt;span style=&amp;quot;font-family: monospace, monospace;&amp;quot;&amp;gt;cmd&amp;lt;/span&amp;gt; syntax to copy the file.&lt;br /&gt;
Enhance the export code as follows to enable builds also on a POSIX system:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;highlight-nsis&amp;gt;&lt;br /&gt;
!ifdef EXPORT_UNINST&lt;br /&gt;
  ; Export the uninstaller for &amp;#039;makensis -DIMPORT_UNINST&amp;#039;&lt;br /&gt;
  !system &amp;#039;exit 256&amp;#039; STATUS ; POSIX systems truncate STATUS to 8 bit&lt;br /&gt;
  !if ${STATUS} = 256 ; Assume native build&lt;br /&gt;
    !uninstfinalize &amp;#039;echo copy /Y &amp;quot;%1&amp;quot; uninstall.exe&amp;amp;copy /Y &amp;quot;%1&amp;quot; uninstall.exe &amp;gt;nul&amp;#039;&lt;br /&gt;
  !else ; Assume cross build&lt;br /&gt;
    !uninstfinalize &amp;#039;cp -fv &amp;quot;%1&amp;quot; uninstall.exe&amp;#039;&lt;br /&gt;
  !endif&lt;br /&gt;
!endif ; EXPORT_UNINST&lt;br /&gt;
&amp;lt;/highlight-nsis&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Code Examples]]&lt;/div&gt;</summary>
		<author><name>ChrFranke</name></author>
	</entry>
</feed>