Archive: Need help with NSIS .NSI file


Need help with NSIS .NSI file
Hello, my name is josh, I am a little new to the program NSIS, in the past i've made dozens of installer program installers with this freeware product, how ever, latley i've been trying to goto the next level of this instillation proccess, in the past I used default installer, *just draging zip into zipexe thing* but now i've been browsing in example folder when GFX.NSI came across me, I really liked the script, I dragged it to script compiler and it showed how it would come out, I loved it, so it took me a while but I configed it to my likes and got no syntax errors in compiler, so for a while I have been trying to get the installer to work with my .ZIP folder, took me a while to figure out, but furthest I got was 1.) C:\Program Files\NSIS\Contrib\zip2exe then adding to base file the NSI code.

here was the non-error code I made from GFX.nsi

; De-Pack.cs
;
; this version of de-pack is designed to replace
; all TRIES 1 models,
;
; INSTRUCTIONS--
; For
; De-Pack(TM) 8.0
; Drag the .exe to desktop, double click .exe
; Then you are good to go! then just run or RESET
; TRIBES then OPEN CONSOLE AKA (`) AND THEN READ
; Then after so it will say type something that
; something is de::list(); type that in console
; To list all pack commands.. newly type p2(); to go
; to pack commands page 2 you can change keys
; and sad passes etc by accsesing De-pack in config
; folder YOU MAY ONLY EDIT UNTIL IT SAYS STOP!
; THIS PACK IS UNDER COPY RIGHT! Pack Made
; by De- HOWEVER Used based code from
; Z0dd Alien ANI Worstaim Big Monkey & TANK
; Thank you for downloading my pack! :D
;
; --8.0
; O-M-G, 8.0! I skipped from 7.7 to 8.0
; becuase this is one of my final MAJOR
; updates, YOU WILL LOVE THIS UPDATE!!
; No more TRIBES 1 box hands, all new
; weapons,packs,skins, models
; EVERYTHING!!! also NOW, no need to be
; in -laggy for some ppl- OpenGL!!! you can
; now play however you'd like no more disc crash!!
; Theres a lot more that you're soon to find out!
;
; --7.7
; v menu fixes, and autoexec fix won't over
; write anymore.
;
; --7.6
; added some more stuff and added all
; the voices since I managed to fix V
; menu enjoy!This is considerd a major
; update, I will make ONE more major
; update after this then
; there will just be very
; minor updates.
;
; --7.5
; Made some bug fixes addes some shizel
; put in more (); commands. and added grafic
; enhancer code automatically putting you in
; openGL mode this also fixes disc crash
; problem added crap(); gocrap(); sadvx();
; ModX skin more +- to V menu and more...
;
;
; --7.4
; mouse wheel changes weapons new plane skin,
; invintory skin, disc launcher explosion,
; and lotz more.
;
;
; --7.3
; Autoboost, shuts off bad word filter,
; auto throws gernades furthest when pressing
; "N" Hold "B" for auto boost. + V menu fix!
;
; --7.2
; now includes server fix, server
; black console command (soff();)
; and some new sounds.reset();
; off(); requires admin
;
; I've stared update notes at 7.2
;
;
;
; Dark energy--
;
;
; any problems questions contact De at
; CMX.2ya.com

;--------------------------------

!macro BIMAGE IMAGE PARMS
Push $0
GetTempFileName $0
File /oname=$0 "${IMAGE}"
SetBrandingImage ${PARMS} $0
Delete $0
Pop $0
!macroend

;--------------------------------

Name "De-Pack"

OutFile "De-Pack.exe"

; Adds an XP manifest to the installer
XPStyle on

; Add branding image to the installer (an image placeholder on the side).
; It is not enough to just add the placeholder, we must set the image too...
; We will later set the image in every pre-page function.
; We can also set just one persistent image in .onGUIInit
AddBrandingImage left 100

; Sets the font of the installer
SetFont "Comic Sans MS" 8

; Just to make it three pages...
SubCaption 0 ": Part 1.) of installing De-pack"
SubCaption 2 ": Part 2.) of installing De-Pack"
LicenseText "License page"
LicenseData "gfx.nsi"
DirText "TRIBES directory to install De-Pack to"

; Install dir
InstallDir "C\:Dynamix\TRIBES"

;--------------------------------

; Pages
Page license licenseImage
Page custom customPage
Page directory dirImage
Page instfiles instImage

;--------------------------------

Section ""
; You can also use the BI_NEXT macro here...
MessageBox MB_YESNO "Are you sure you want to go on with$\ninstalling De-Pack?" IDNO done
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Wizard\nsis.bmp" ""
done:
WriteUninstaller uninst.exe
SectionEnd

;--------------------------------

Function licenseImage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Header\nsis.bmp" /RESIZETOFIT
MessageBox MB_YESNO 'Would you like to skip the De-Pack information/license page?' IDNO no
Abort
no:
FunctionEnd

Function customPage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Checks\modern.bmp" /RESIZETOFIT
MessageBox MB_OK 'Make sure you save previous admin passes/modx passes before installing!'
#insert install options/start menu/<insert plugin name here> here
FunctionEnd

Function dirImage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Header\win.bmp" /RESIZETOFIT
FunctionEnd

Function instImage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Wizard\llama.bmp" /RESIZETOFIT
FunctionEnd

;--------------------------------

; Uninstall pages

UninstPage uninstConfirm un.uninstImage
UninstPage custom un.customPage
UninstPage instfiles un.instImage

Function un.uninstImage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Checks\modern.bmp" /RESIZETOFIT
FunctionEnd

Function un.customPage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Header\win.bmp" /RESIZETOFIT
MessageBox MB_OK 'Getting ready to uninstall De-Pack...'
#insert install options/start menu/<insert plugin name here> here
FunctionEnd

Function un.instImage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Wizard\llama.bmp" /RESIZETOFIT
FunctionEnd

;--------------------------------

; Uninstaller

; Another page for uninstaller
UninstallText "Uninstalling De-Pack"

Section uninstall
MessageBox MB_OK "Are you sure you want to remove De-Pack?"
SectionEnd





Like I said I added it to base file *this code that is* outcome was, it came out good it worked I had output EXE file as GFX.exe on my desktop and I dragged my zip into source zip file the installer worked, only problem was, it didn't install my files, I didn't getthe GFX installer screen until adding gfx.nsi code to base script, so basically my problem is, I got GFX installer to work, I just can't get my files to work/install, when I click install only the uninstaller installs to the destination folder. So please, if anyone has any suggestions, what am I doing wrong, please contact me or post to this topic my website is CMX.2ya.com email me at ModXhelp@hotmail.com.

Instead of completely replacing Base.nsh, you need to modify it. All of the macros in it are required for file extraction. Replace the 6 first lines (up until the first !ifdef) in Base.nsh and it should work.


But then I won't have the custom installer? Do I like copy and paste the macros to GFX code, or what?


It would help due to my *stupidness* if you can just paste the base code that should work, this has been giving me a headache I am new to coding this type of file, I'm pro at HTML and .cs coding, but this is odd for me, thank god for basic code knowledge of .cs scripting, or else I wouldn't have got this far, so please if you could, just edit the code above to fit base like you were saying.


Yeah I would be real thankful if anyone can help me by making the zip extract files to work with this installer.


Ok if anyone can help me with my problem, please forward an email to: ModXhelp@hotmail.com

Thanks


I'm not sure what you're trying to achieve, are you trying to use the same look like gfx for your installer?
If so you need to make some modifications, e.g. sections executed when users hit Install button, so it won't look nice to ask them with a message box if they are sure about :)
Probably you don't need the custom page referred in gfx.
Also probably you want to add you own graphics instead, include your own license and add your files in installer/uninstaller sections.
I'd suggest start working with a simple installer to help you understand how to install/uninstall files/folders.


Dark-energy, all you need to is replace the first 6 lines of the original Base.nsh with the contents of gfx.nsi.


So first 6 lines of base.nsh I put the GFX code there like "combinding the 2 codes together" or what?


The whole entire GFX code if thats right also?


Yes, the entire GFX and it's combining them.


Alright i'll try, so first 6 lines of base.nsh replaces those 6 lines with GFX


Ok I tried it, however the results came out just the same, I put GFX (slightly moddified for my instillation) in base.nsh until I reached the first !def, I got no errors when doing this, so I thought it should work, then I put gfx.exe on desktop then my zip in in Zip2EXE and made outputexe gfx.exe, again, no errors I ran insillation to a blank destination folder, the thing that went wrong is, the files that were in zip2exe did not extract to folder, instead, only the uninstaller extracted, here is the base.nsh I put together from original base until !def line with slightly non-error modded GFX.nsi combined heres the outcome code. But again my selected files will not extract!

; De-Pack.cs
;
; this version of de-pack is designed to replace
; all TRIES 1 models,
;
; INSTRUCTIONS--
; For
; De-Pack(TM) 8.0
; Drag the .exe to desktop, double click .exe
; Then you are good to go! then just run or RESET
; TRIBES then OPEN CONSOLE AKA (`) AND THEN READ
; Then after so it will say type something that
; something is de::list(); type that in console
; To list all pack commands.. newly type p2(); to go
; to pack commands page 2 you can change keys
; and sad passes etc by accsesing De-pack in config
; folder YOU MAY ONLY EDIT UNTIL IT SAYS STOP!
; THIS PACK IS UNDER COPY RIGHT! Pack Made
; by De- HOWEVER Used based code from
; Z0dd Alien ANI Worstaim Big Monkey & TANK
; Thank you for downloading my pack! :D
;
; --8.0
; O-M-G, 8.0! I skipped from 7.7 to 8.0
; becuase this is one of my final MAJOR
; updates, YOU WILL LOVE THIS UPDATE!!
; No more TRIBES 1 box hands, all new
; weapons,packs,skins, models
; EVERYTHING!!! also NOW, no need to be
; in -laggy for some ppl- OpenGL!!! you can
; now play however you'd like no more disc crash!!
; Theres a lot more that you're soon to find out!
;
; --7.7
; v menu fixes, and autoexec fix won't over
; write anymore.
;
; --7.6
; added some more stuff and added all
; the voices since I managed to fix V
; menu enjoy!This is considerd a major
; update, I will make ONE more major
; update after this then
; there will just be very
; minor updates.
;
; --7.5
; Made some bug fixes addes some shizel
; put in more (); commands. and added grafic
; enhancer code automatically putting you in
; openGL mode this also fixes disc crash
; problem added crap(); gocrap(); sadvx();
; ModX skin more +- to V menu and more...
;
;
; --7.4
; mouse wheel changes weapons new plane skin,
; invintory skin, disc launcher explosion,
; and lotz more.
;
;
; --7.3
; Autoboost, shuts off bad word filter,
; auto throws gernades furthest when pressing
; "N" Hold "B" for auto boost. + V menu fix!
;
; --7.2
; now includes server fix, server
; black console command (soff();)
; and some new sounds.reset();
; off(); requires admin
;
; I've stared update notes at 7.2
;
;
;
; Dark energy--
;
;
; any problems questions contact De at
; CMX.2ya.com

;--------------------------------

!macro BIMAGE IMAGE PARMS
Push $0
GetTempFileName $0
File /oname=$0 "${IMAGE}"
SetBrandingImage ${PARMS} $0
Delete $0
Pop $0
!macroend

;--------------------------------

Name "De-Pack"

OutFile "De-Pack.exe"

; Adds an XP manifest to the installer
XPStyle on

; Add branding image to the installer (an image placeholder on the side).
; It is not enough to just add the placeholder, we must set the image too...
; We will later set the image in every pre-page function.
; We can also set just one persistent image in .onGUIInit
AddBrandingImage left 100

; Sets the font of the installer
SetFont "Comic Sans MS" 8

; Just to make it three pages...
SubCaption 0 ": Part 1.) of installing De-pack"
SubCaption 2 ": Part 2.) of installing De-Pack"
LicenseText "License page"
LicenseData "gfx.nsi"
DirText "TRIBES directory to install De-Pack to"

; Install dir
InstallDir "C\:Dynamix\TRIBES"

;--------------------------------

; Pages
Page license licenseImage
Page custom customPage
Page directory dirImage
Page instfiles instImage

;--------------------------------

Section ""
; You can also use the BI_NEXT macro here...
MessageBox MB_YESNO "Are you sure you want to go on with$\ninstalling De-Pack?" IDNO done
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Wizard\nsis.bmp" ""
done:
WriteUninstaller uninst.exe
SectionEnd

;--------------------------------

Function licenseImage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Header\nsis.bmp" /RESIZETOFIT
MessageBox MB_YESNO 'Would you like to skip the De-Pack information/license page?' IDNO no
Abort
no:
FunctionEnd

Function customPage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Checks\modern.bmp" /RESIZETOFIT
MessageBox MB_OK 'Make sure you save previous admin passes/modx passes before installing!'
#insert install options/start menu/<insert plugin name here> here
FunctionEnd

Function dirImage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Header\win.bmp" /RESIZETOFIT
FunctionEnd

Function instImage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Wizard\llama.bmp" /RESIZETOFIT
FunctionEnd

;--------------------------------

; Uninstall pages

UninstPage uninstConfirm un.uninstImage
UninstPage custom un.customPage
UninstPage instfiles un.instImage

Function un.uninstImage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Checks\modern.bmp" /RESIZETOFIT
FunctionEnd

Function un.customPage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Header\win.bmp" /RESIZETOFIT
MessageBox MB_OK 'Getting ready to uninstall De-Pack...'
#insert install options/start menu/<insert plugin name here> here
FunctionEnd

Function un.instImage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\Wizard\llama.bmp" /RESIZETOFIT
FunctionEnd

;--------------------------------

; Uninstaller

; Another page for uninstaller
UninstallText "Uninstalling De-Pack"

Section uninstall
MessageBox MB_OK "Are you sure you want to remove De-Pack?"
SectionEnd



!ifdef ZIP2EXE_INSTALLDIR

InstallDir "${ZIP2EXE_INSTALLDIR}"

Function zip2exe.SetOutPath
SetOutPath "$INSTDIR"
FunctionEnd

!else ifdef ZIP2EXE_INSTALLDIR_WINAMP

InstallDir "$PROGRAMFILES\Winamp"
InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" "UninstallString"

Function .onVerifyInstDir
IfFileExists $INSTDIR\winamp.exe WinampInstalled
Abort
WinampInstalled:
FunctionEnd

!ifdef ZIP2EXE_INSTALLDIR_WINAMPMODE

Var ZIP2EXE_TEMP1
Var ZIP2EXE_TEMP2

Function zip2exe.SetOutPath
!ifdef ZIP2EXE_INSTALLDIR_SKINS
StrCpy $ZIP2EXE_TEMP1 "$INSTDIR\Skins"
!else
StrCpy $ZIP2EXE_TEMP1 "$INSTDIR\Plugins"
!endif
ReadINIStr $ZIP2EXE_TEMP2 "$INSTDIR\winamp.ini" "Winamp" "${ZIP2EXE_INSTALLDIR_WINAMPMODE}"
StrCmp $ZIP2EXE_TEMP2 "" End
IfFileExists $ZIP2EXE_TEMP2 0 End
StrCpy $ZIP2EXE_TEMP1 $ZIP2EXE_TEMP2
End:
SetOutPath $ZIP2EXE_TEMP1
FunctionEnd

!else

Function zip2exe.SetOutPath
!ifdef ZIP2EXE_INSTALLDIR_PLUGINS
SetOutPath "$INSTDIR\Plugins"
!else
SetOutPath "$INSTDIR"
!endif
FunctionEnd

!endif

!endif

!macro SECTION_BEGIN

Section ""

Call zip2exe.SetOutPath

!macroend

!macro SECTION_END

SectionEnd

!macroend


Aha, I did get an error now
!include: error in script: "C:\Program Files\NSIS\Contrib\zip2exe\Base.nsh" on line 116
Error in script "C:\DOCUME~1\HaCKeR\LOCALS~1\Temp\zne30.tmp" on line 5 -- aborting creation process


gah, I am still stuck though...


That's not the error itself. That just part of the error trace. Look at the lines above it and you'll find your real error.


We'll, I kind of am losing hope, I would apreciate if someone could help me put this code together correctly becuase I don't code this for a living, I would be so thankful if someone can just put original GFX.nsi with base so installer works, then i'll just add the simple modifications, I just want GFX and the file extracter to work, so please someone if you can, just paste base.nsh code for GFX installer, with working file extracting code or w/e. Thanks a lot anyways--

Joshua Stephens


Not sure if it has anything to do with your problem but you have :


; Install dir
InstallDir "C\ : Dynamix\TRIBES"

it should be c:\Dynamix\TRIBES surely ? ( \ and : need reversing )

Fish

I already fixed that to C:\Dynamix\TRIBES I seen that that wouldn't be a problem anyways, can someone plainly tell me how to make GFX.NSI Converted to Base.NSH so the installer works?