Skip to content

Instantly share code, notes, and snippets.

@xymopen
Last active June 12, 2016 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xymopen/951ef3d5301af55efd82eb67af129066 to your computer and use it in GitHub Desktop.
Save xymopen/951ef3d5301af55efd82eb67af129066 to your computer and use it in GitHub Desktop.
A SFX archive script for NSIS
!define SFX_NAME ""
!define SFX_DIR ""
!define SFX_RUN "$INSTDIR\Setup.exe"
!define SFX_ICON ""
!define SFX_OUT ""
VIFileVersion "0.0.0.0"
VIProductVersion "0.0.0.0"
VIAddVersionKey "FileVersion" "0.0.0.0"
VIAddVersionKey "ProductVersion" "0.0.0.0"
VIAddVersionKey "FileDescription" ""
VIAddVersionKey "ProductName" ""
VIAddVersionKey "InternalName" ""
VIAddVersionKey "CompanyName" ""
VIAddVersionKey "LegalCopyright" ""
VIAddVersionKey "LegalTrademarks" ""
VIAddVersionKey "OriginalFilename" ""
# src: http://nsis.sourceforge.net/ShellExecWait
!include LogicLib.nsh
!include WinMessages.nsh
!macro ExecShellWait action command parameters show_window
System::Store S
System::Call '*(&i60)i.r0'
System::Call '*$0(i 60,i 0x40,i $hwndparent,t "${action}",t $\'${command}$\',t $\'${parameters}$\',t "$OUTDIR",i ${show_window})i.r0'
System::Call 'shell32::ShellExecuteEx(ir0)i.r1 ?e'
${If} $1 <> 0
System::Call '*$0(is,i,i,i,i,i,i,i,i,i,i,i,i,i,i.r1)' ; stack value not really used, just a fancy pop ;)
System::Call 'kernel32::WaitForSingleObject(ir1,i-1)'
System::Call 'kernel32::GetExitCodeProcess(ir1,*i.s)'
System::Call 'kernel32::CloseHandle(ir1)'
${EndIf}
System::Store L
!macroend
Name ${SFX_NAME}
Icon '${SFX_ICON}'
OutFile '${SFX_OUT}'
InstallDir '$TEMP\${SFX_NAME}'
RequestExecutionLevel user
SilentInstall silent
Section "Install"
SetOutPath '$INSTDIR'
File /r '${SFX_DIR}'
!insertmacro ExecShellWait "" '${SFX_RUN}' "" ${SW_SHOWNORMAL}
RMDir /r '$OUTDIR'
SectionEnd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment