Using !packhdr: Difference between revisions
No edit summary |
|||
Line 28: | Line 28: | ||
== Usage == | == Usage == | ||
You can put this code into a NSIS\Include\Packhdr.nsh file: | |||
You can put this code into | |||
<highlight-nsis> | <highlight-nsis> | ||
!ifndef _Packhdr_Included | !ifndef _Packhdr_Included | ||
Line 52: | Line 45: | ||
!endif | !endif | ||
</highlight-nsis> | </highlight-nsis> | ||
Then use the following at the top of your NSIS scripts: | |||
<highlight-nsis> | <highlight-nsis> | ||
!define Packhdr upx | !define Packhdr upx | ||
!include Packhdr.nsh | !include Packhdr.nsh | ||
</highlight-nsis> | </highlight-nsis> | ||
I use ''upx+noicon'' for utility executables that are written in NSIS but do not serve a purpose as an installation wizard (i.e. ''SilentInstall silent''). | |||
[[Category:Tutorials]] | [[Category:Tutorials]] |
Revision as of 15:19, 24 July 2010
Author: Afrow UK (talk, contrib) |
!packhdr
!packhdr is a useful compile time directive which allows modifications to the built installer executable header before it is written to the finished installer executable file. It can be used to pack the executable header using UPX or edit resources using Resource Hacker. I have used !packhdr for many years in conjunction with some useful batch files to:
- Pack the header (UPX)
- Pack the header (UPX) and remove the installer icon (Resource Hacker)
Batch files
Firstly you will need to download UPX and Resource Hacker and copy upx.exe and reshacker.exe to a new NSIS\Packhdr folder. Then place the following batch files in the NSIS\Packhdr folder:
upx.bat
cd /d %~dp0 upx --best %1
upx+noicon.bat
cd /d %~dp0 ResHacker -delete %1, %1, icongroup,103, del ResHacker.log upx --best %1
Usage
You can put this code into a NSIS\Include\Packhdr.nsh file:
!ifndef _Packhdr_Included !define _Packhdr_Included !if `${Packhdr}` != upx !if `${Packhdr}` != upx+noicon !error `Packhdr must be defined as: upx | upx+noicon` !endif !endif !packhdr $%TEMP%\exehead.tmp `"${NSISDIR}\packhdr\${Packhdr}.bat" "$%TEMP%\exehead.tmp"` !undef Packhdr !endif
Then use the following at the top of your NSIS scripts:
!define Packhdr upx !include Packhdr.nsh
I use upx+noicon for utility executables that are written in NSIS but do not serve a purpose as an installation wizard (i.e. SilentInstall silent).