Windows single file executable

From HippoHX

Jump to: navigation, search

Some people might not like the idea that users can see the bunch of dlls files needed by SWHX applications. For Mac applications is actually not that bad because everything is somehow hidden in the *.app folder. However Windows users are most likely to see all Neko and SWHX files. You can avoid this using a "silent installer".

Ian Thomas gently shared an easy an free way of solving this problem:

  • Compile your application using HippoHX.
  • Download and install NSIS.
  • Update the NSIS script bellow with your data and copy it to the folder where all your files are. You just have to update 3 pieces of data "YourFinalExeNameHere", "YourIconHere", "YourMainExeNameHere".
  • Run the script via right click on > Compile NSIS script.
  • Voilá!

Now you should have an executable that you can double click to run your app. What it does is silently unpacking your files to a temp folder and run your main application.

Why not adding this to HippoHX?

Well, mostly because it would complicate things:

  • We would have to redistribute NSIS with HippoHX, and this might cause licensing issues.
  • Redistributing NSIS would also mean keeping it updated with new releases.
  • We couldn't offer this feature to Mac users creating Win apps because NSIS seems to be Windows only (to be confirmed).

We think the solution is easy enough so anyone really interested can use it. But if you feel this feature really, really, really, really should be included in HippoHX, just pop by the mailing list and make some noise about it.

Thanks again to Ian for sharing!

; NSIS script to package up all the files in the current
; folder - when the resulting .exe is run,
; all the files are unpacked into a temporary folder
; and a projector file is run.
;
; by Ian Thomas at Awen, 2006
;
; -------------------------------------
; IMPORTANT: Place the name of your resulting app - 
; i.e. the one the user will click on - here:
OutFile "YourFinalExeNameHere.exe"
; IMPORTANT: The icon file to use for your output app
Icon "YourIconHere.ico"
 
SilentInstall silent
SetCompress Off
RequestExecutionLevel user
 
Section
 
    ; Generate a temp file name
	GetTempFileName $0
	; Delete it and replace it with a folder
	Delete $0
	CreateDirectory $0
 
	; Report any problem	
	IFErrors 0 +2
	  Abort "Can't create temp folder! Please contact support."
 
	; Unpack files
	SetOutPath $0
 
	; Pack all the files in the current directory and its subdirectories,
	; excluding anything in SVN
	File /r /x .svn "*.*"
 
	; Run the executable and wait
	ClearErrors
	SetOutPath "$0\"
 
	; IMPORTANT: Place the name of your starting executable (i.e. the file to run
	; when unpacked) here.
	ExecWait "YourMainExeNameHere.exe"
 
	IFErrors 0 +2
  	  Abort "Can't run app! Please contact support."
 
  	; And delete the unpacked files
  	ClearErrors
  	SetOutPath $TEMP ; Need to do this because we can't delete the working folder
	RMDir /r $0 ; If there's an error we probably don't really care, as it's in a temp folder
 
SectionEnd
Personal tools