updated format, small changes

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2282 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
joostverburg 2003-03-11 20:44:48 +00:00
parent 39a9897cd8
commit 92acc0dd32
8 changed files with 394 additions and 233 deletions

View file

@ -1,7 +1,9 @@
; bigtest.nsi ; bigtest.nsi
; ;
; This script attempts to test most of the functionality of NSIS. ; This script attempts to test most of the functionality of the NSIS exehead.
;
;--------------------------------
!ifdef HAVE_UPX !ifdef HAVE_UPX
!packhdr tmp.dat "upx\upx -9 tmp.dat" !packhdr tmp.dat "upx\upx -9 tmp.dat"
!endif !endif
@ -10,6 +12,13 @@
SetCompress off SetCompress off
!endif !endif
;--------------------------------
Name "BigNSISTest"
Caption "NSIS Big Test"
Icon "..\contrib\Icons\normal-install.ico"
OutFile "bigtest.exe"
SetDateSave on SetDateSave on
SetDatablockOptimize on SetDatablockOptimize on
CRCCheck on CRCCheck on
@ -18,56 +27,52 @@ BGGradient 000000 800000 FFFFFF
InstallColors FF8080 000030 InstallColors FF8080 000030
XPStyle on XPStyle on
Name "BigNSISTest" LicenseText "A license text, make sure it's all there"
Caption "NSIS Big Test"
Icon "..\contrib\Icons\normal-install.ico"
OutFile "bigtest.exe"
LicenseText "make sure this license text is all there (it's about 28k last I checked). The last line is a simple '}'."
LicenseData "..\source\exehead\main.c" LicenseData "..\source\exehead\main.c"
InstallDir "$PROGRAMFILES\NSISCrap\BigNSISTest" InstallDir "$PROGRAMFILES\NSISCrap\BigNSISTest"
InstallDirRegKey HKLM SOFTWARE\NSISCrap\BigNSISTest "Install_Dir" InstallDirRegKey HKLM SOFTWARE\NSISCrap\BigNSISTest "Install_Dir"
DirText "Choose a directory to install in to:" DirText "Choose a directory to install in to:"
; uninstall stuff
UninstallText "This will uninstall example2. Hit next to continue."
UninstallIcon "..\contrib\Icons\normal-uninstall.ico"
ComponentText "This will install the test on your computer. Select which optional things you want installed." ComponentText "This will install the test on your computer. Select which optional things you want installed."
CheckBitmap ..\contrib\Icons\checksX.bmp CheckBitmap ..\contrib\Icons\checksX.bmp
!ifndef NOINSTTYPES ; only if not defined !ifndef NOINSTTYPES ; only if not defined
InstType "Most" InstType "Most"
InstType "Full" InstType "Full"
InstType "More" InstType "More"
InstType "Base" InstType "Base"
;InstType /NOCUSTOM ;InstType /NOCUSTOM
;InstType /COMPONENTSONLYONCUSTOM ;InstType /COMPONENTSONLYONCUSTOM
!endif !endif
AutoCloseWindow false AutoCloseWindow false
ShowInstDetails show ShowInstDetails show
;--------------------------------
Section "" ; empty string makes it hidden, so would starting with - Section "" ; empty string makes it hidden, so would starting with -
; write reg crap
StrCpy $1 "POOOOOOOOOOOP"
DetailPrint "I like to f*ck sheep $1"
WriteRegStr HKLM SOFTWARE\NSISCrap\BigNSISTest "Install_Dir" "$INSTDIR"
; write uninstall strings
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest" "DisplayName" "BigNSISTest (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest" "UninstallString" '"$INSTDIR\bt-uninst.exe"'
#File /oname=poop.exe makensisw.exe
SetOutPath $INSTDIR ; write reg crap
File /a "..\source\exehead\bin2h.exe" StrCpy $1 "POOOOOOOOOOOP"
CreateDirectory "$INSTDIR\shiz\crap" ; 2 recursively create a directory for fun. DetailPrint "I like to f*ck sheep $1"
WriteUninstaller "bt-uninst.exe" WriteRegStr HKLM SOFTWARE\NSISCrap\BigNSISTest "Install_Dir" "$INSTDIR"
Nop ; for fun
; write uninstall strings
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest" "DisplayName" "BigNSISTest (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest" "UninstallString" '"$INSTDIR\bt-uninst.exe"'
SetOutPath $INSTDIR
File /a "..\source\exehead\bin2h.exe"
CreateDirectory "$INSTDIR\shiz\crap" ; 2 recursively create a directory for fun.
WriteUninstaller "bt-uninst.exe"
Nop ; for fun
SectionEnd SectionEnd
Section "TempTest" Section "TempTest"
SectionIn 1 2 3 SectionIn 1 2 3
Start: MessageBox MB_OK "Start:" Start: MessageBox MB_OK "Start:"
@ -83,151 +88,170 @@ SectionIn 1 2 3
SectionEnd SectionEnd
Function poopTest
ReadINIStr $1 "$INSTDIR\test.ini" "MySectionShit" "Value1"
StrCmp $1 $8 NoFailedMsg
MessageBox MB_OK "WriteINIStr failed"
NoFailedMsg: FunctionEnd
SubSection /e SubSection1 SubSection /e SubSection1
Section "Test Registry/INI functions" Section "Test Registry/INI functions"
SectionIn 1 4 3 SectionIn 1 4 3
WriteRegStr HKLM SOFTWARE\NSISCrap\BigNSISTest "StrTest_INSTDIR" "$INSTDIR"
WriteRegDword HKLM SOFTWARE\NSISCrap\BigNSISTest "DwordTest_0xDEADBEEF" 0xdeadbeef
WriteRegDword HKLM SOFTWARE\NSISCrap\BigNSISTest "DwordTest_123456" 123456
WriteRegDword HKLM SOFTWARE\NSISCrap\BigNSISTest "DwordTest_0123" 0123
WriteRegBin HKLM SOFTWARE\NSISCrap\BigNSISTest "BinTest_deadbeef01f00dbeef" "DEADBEEF01F00DBEEF"
StrCpy $8 "$SYSDIR\Poop"
WriteINIStr "$INSTDIR\test.ini" "MySection" "Value1" $8
WriteINIStr "$INSTDIR\test.ini" "MySectionShit" "Value1" $8
WriteINIStr "$INSTDIR\test.ini" "MySectionShit" "Value2" $8
WriteINIStr "$INSTDIR\test.ini" "POOPon" "Value1" $8
Call poopTest
DeleteINIStr "$INSTDIR\test.ini" "POOPon" "Value1" WriteRegStr HKLM SOFTWARE\NSISCrap\BigNSISTest "StrTest_INSTDIR" "$INSTDIR"
DeleteINISec "$INSTDIR\test.ini" "MySectionShit" WriteRegDword HKLM SOFTWARE\NSISCrap\BigNSISTest "DwordTest_0xDEADBEEF" 0xdeadbeef
WriteRegDword HKLM SOFTWARE\NSISCrap\BigNSISTest "DwordTest_123456" 123456
WriteRegDword HKLM SOFTWARE\NSISCrap\BigNSISTest "DwordTest_0123" 0123
WriteRegBin HKLM SOFTWARE\NSISCrap\BigNSISTest "BinTest_deadbeef01f00dbeef" "DEADBEEF01F00DBEEF"
StrCpy $8 "$SYSDIR\Poop"
WriteINIStr "$INSTDIR\test.ini" "MySection" "Value1" $8
WriteINIStr "$INSTDIR\test.ini" "MySectionShit" "Value1" $8
WriteINIStr "$INSTDIR\test.ini" "MySectionShit" "Value2" $8
WriteINIStr "$INSTDIR\test.ini" "POOPon" "Value1" $8
ReadINIStr $1 "$INSTDIR\test.ini" "MySectionShit" "Value1" Call poopTest
StrCmp $1 "" INIDelSuccess
MessageBox MB_OK "DeleteINISec failed"
INIDelSuccess:
ClearErrors DeleteINIStr "$INSTDIR\test.ini" "POOPon" "Value1"
ReadRegStr $1 HKCR "software\microsoft" shit DeleteINISec "$INSTDIR\test.ini" "MySectionShit"
IfErrors 0 NoError
MessageBox MB_OK "could not read from HKCR\software\microsoft\shit" ReadINIStr $1 "$INSTDIR\test.ini" "MySectionShit" "Value1"
Goto ErrorYay StrCmp $1 "" INIDelSuccess
NoError: MessageBox MB_OK "DeleteINISec failed"
MessageBox MB_OK "read '$1' from HKCR\software\microsoft\shit" INIDelSuccess:
ErrorYay:
ClearErrors
ReadRegStr $1 HKCR "software\microsoft" shit
IfErrors 0 NoError
MessageBox MB_OK "could not read from HKCR\software\microsoft\shit"
Goto ErrorYay
NoError:
MessageBox MB_OK "read '$1' from HKCR\software\microsoft\shit"
ErrorYay:
SectionEnd SectionEnd
Function "CSCTest"
CreateDirectory "$SMPROGRAMS\Big NSIS Test"
SetOutPath $INSTDIR ; for working directory
CreateShortCut "$SMPROGRAMS\Big NSIS Test\Uninstall BIG NSIS Test.lnk" "$INSTDIR\bt-uninst.exe" ; use defaults for parameters, icon, etc.
; this one will use notepad's icon, start it minimized, and give it a hotkey (of Ctrl+Shift+Q)
CreateShortCut "$SMPROGRAMS\Big NSIS Test\bin2h.exe.lnk" "$INSTDIR\bin2h.exe" "" "$WINDIR\notepad.exe" 0 SW_SHOWMINIMIZED CONTROL|SHIFT|Q
CreateShortCut "$SMPROGRAMS\Big NSIS Test\TheDir.lnk" "$INSTDIR\" "" "" 0 SW_SHOWMAXIMIZED CONTROL|SHIFT|Z
FunctionEnd
Section "Test CreateShortCut" Section "Test CreateShortCut"
SectionIn 1 2 3
Call CSCTest SectionIn 1 2 3
Call CSCTest
SectionEnd SectionEnd
SubSection Sub2 SubSection Sub2
Function myfunc
StrCpy $2 "poop=$1"
MessageBox MB_OK "myfunc: $2"
FunctionEnd
Section "Test Branching" Section "Test Branching"
BeginTestSection:
SectionIn 1 2 3 BeginTestSection:
SetOutPath $INSTDIR SectionIn 1 2 3
IfFileExists "$INSTDIR\bin2h.c" 0 BranchTest69
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to overwrite $INSTDIR\bin2h.c?" IDNO NoOverwrite ; skipped if file doesn't exist SetOutPath $INSTDIR
BranchTest69:
SetOverwrite ifnewer ; NOT AN INSTRUCTION, NOT COUNTED IN SKIPPINGS
NoOverwrite:
File "..\source\exehead\bin2h.c" ; skipped if answered no
SetOverwrite try ; NOT AN INSTRUCTION, NOT COUNTED IN SKIPPINGS
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to skip the rest of this section?" IDYES EndTestBranch
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to go back to the beginning of this section?" IDYES BeginTestSection
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to hide the installer and wait five seconds?" IDNO NoHide
HideWindow
Sleep 5000
BringToFront
NoHide:
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to call the function 5 times?" IDNO NoRecurse
StrCpy $1 "x"
LoopPoop:
Call myfunc
StrCpy $1 "x$1"
StrCmp $1 "xxxxxx" 0 LoopPoop
NoRecurse:
EndTestBranch: IfFileExists "$INSTDIR\bin2h.c" 0 BranchTest69
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to overwrite $INSTDIR\bin2h.c?" IDNO NoOverwrite ; skipped if file doesn't exist
BranchTest69:
SetOverwrite ifnewer ; NOT AN INSTRUCTION, NOT COUNTED IN SKIPPINGS
NoOverwrite:
File "..\source\exehead\bin2h.c" ; skipped if answered no
SetOverwrite try ; NOT AN INSTRUCTION, NOT COUNTED IN SKIPPINGS
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to skip the rest of this section?" IDYES EndTestBranch
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to go back to the beginning of this section?" IDYES BeginTestSection
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to hide the installer and wait five seconds?" IDNO NoHide
HideWindow
Sleep 5000
BringToFront
NoHide:
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to call the function 5 times?" IDNO NoRecurse
StrCpy $1 "x"
LoopPoop:
Call myfunc
StrCpy $1 "x$1"
StrCmp $1 "xxxxxx" 0 LoopPoop
NoRecurse:
EndTestBranch:
SectionEnd SectionEnd
SubSectionEnd SubSectionEnd
Section "Test CopyFiles" Section "Test CopyFiles"
SectionIn 1 2 3
SetOutPath $INSTDIR\cpdest SectionIn 1 2 3
CopyFiles "$WINDIR\*.ini" "$INSTDIR\cpdest" 0
SetOutPath $INSTDIR\cpdest
CopyFiles "$WINDIR\*.ini" "$INSTDIR\cpdest" 0
SectionEnd SectionEnd
SubSectionEnd SubSectionEnd
Section "Test Exec functions" CRAPIDX Section "Test Exec functions" CRAPIDX
SectionIn 1 2 3
SearchPath $1 notepad.exe SectionIn 1 2 3
MessageBox MB_OK "notepad.exe=$1"
Exec '"$1"' SearchPath $1 notepad.exe
ExecShell "open" '"$INSTDIR"'
Sleep 500 MessageBox MB_OK "notepad.exe=$1"
BringToFront Exec '"$1"'
ExecShell "open" '"$INSTDIR"'
Sleep 500
BringToFront
SectionEnd SectionEnd
Section "Test ActiveX control registration" Section "Test ActiveX control registration"
SectionIn 2
UnRegDLL "$SYSDIR\spin32.ocx" SectionIn 2
Sleep 1000
RegDLL "$SYSDIR\spin32.ocx" UnRegDLL "$SYSDIR\spin32.ocx"
Sleep 1000 Sleep 1000
RegDLL "$SYSDIR\spin32.ocx"
Sleep 1000
SectionEnd SectionEnd
; special uninstall section. ;--------------------------------
Section "Uninstall"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest"
DeleteRegKey HKLM "SOFTWARE\NSISCrap\BigNSISTest"
Delete "$INSTDIR\bin2h.exe"
Delete "$INSTDIR\bin2h.c"
Delete "$INSTDIR\bt-uninst.exe"
Delete "$INSTDIR\test.ini"
Delete "$SMPROGRAMS\Big NSIS Test\*.*"
RMDir "$SMPROGRAMS\BiG NSIS Test"
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to remove the directory $INSTDIR\cpdest?" IDNO NoDelete
Delete "$INSTDIR\cpdest\*.*"
RMDir "$INSTDIR\cpdest" ; skipped if no
NoDelete:
RMDir "$INSTDIR\shiz\crap"
RMDir "$INSTDIR\shiz"
RMDir "$INSTDIR"
IfFileExists "$INSTDIR" 0 NoErrorMsg
MessageBox MB_OK "Note: $INSTDIR could not be removed!" IDOK 0 ; skipped if file doesn't exist
NoErrorMsg:
SectionEnd
; eof Function "CSCTest"
CreateDirectory "$SMPROGRAMS\Big NSIS Test"
SetOutPath $INSTDIR ; for working directory
CreateShortCut "$SMPROGRAMS\Big NSIS Test\Uninstall BIG NSIS Test.lnk" "$INSTDIR\bt-uninst.exe" ; use defaults for parameters, icon, etc.
; this one will use notepad's icon, start it minimized, and give it a hotkey (of Ctrl+Shift+Q)
CreateShortCut "$SMPROGRAMS\Big NSIS Test\bin2h.exe.lnk" "$INSTDIR\bin2h.exe" "" "$WINDIR\notepad.exe" 0 SW_SHOWMINIMIZED CONTROL|SHIFT|Q
CreateShortCut "$SMPROGRAMS\Big NSIS Test\TheDir.lnk" "$INSTDIR\" "" "" 0 SW_SHOWMAXIMIZED CONTROL|SHIFT|Z
FunctionEnd
Function myfunc
StrCpy $2 "poop=$1"
MessageBox MB_OK "myfunc: $2"
FunctionEnd
Function poopTest
ReadINIStr $1 "$INSTDIR\test.ini" "MySectionShit" "Value1"
StrCmp $1 $8 NoFailedMsg
MessageBox MB_OK "WriteINIStr failed"
NoFailedMsg:
FunctionEnd
Function .onSelChange Function .onSelChange
SectionGetText ${CRAPIDX} $0 SectionGetText ${CRAPIDX} $0
StrCmp $0 "" e StrCmp $0 "" e
SectionSetText ${CRAPIDX} "" SectionSetText ${CRAPIDX} ""
@ -237,3 +261,36 @@ e:
e2: e2:
FunctionEnd FunctionEnd
;--------------------------------
; Uninstaller
UninstallText "This will uninstall example2. Hit next to continue."
UninstallIcon "..\contrib\Icons\normal-uninstall.ico"
Section "Uninstall"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest"
DeleteRegKey HKLM "SOFTWARE\NSISCrap\BigNSISTest"
Delete "$INSTDIR\bin2h.exe"
Delete "$INSTDIR\bin2h.c"
Delete "$INSTDIR\bt-uninst.exe"
Delete "$INSTDIR\test.ini"
Delete "$SMPROGRAMS\Big NSIS Test\*.*"
RMDir "$SMPROGRAMS\BiG NSIS Test"
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to remove the directory $INSTDIR\cpdest?" IDNO NoDelete
Delete "$INSTDIR\cpdest\*.*"
RMDir "$INSTDIR\cpdest" ; skipped if no
NoDelete:
RMDir "$INSTDIR\shiz\crap"
RMDir "$INSTDIR\shiz"
RMDir "$INSTDIR"
IfFileExists "$INSTDIR" 0 NoErrorMsg
MessageBox MB_OK "Note: $INSTDIR could not be removed!" IDOK 0 ; skipped if file doesn't exist
NoErrorMsg:
SectionEnd

View file

@ -4,7 +4,8 @@
; optional settings are left to their default settings. The installer simply ; optional settings are left to their default settings. The installer simply
; prompts the user asking them where to install, and drops a copy of makensisw.exe ; prompts the user asking them where to install, and drops a copy of makensisw.exe
; there. ; there.
;
;--------------------------------
; The name of the installer ; The name of the installer
Name "Example1" Name "Example1"
@ -18,12 +19,15 @@ InstallDir $PROGRAMFILES\Example1
; The text to prompt the user to enter a directory ; The text to prompt the user to enter a directory
DirText "This will install the very simple example1 on your computer. Choose a directory" DirText "This will install the very simple example1 on your computer. Choose a directory"
;--------------------------------
; The stuff to install ; The stuff to install
Section "ThisNameIsIgnoredSoWhyBother?" Section "" ;Only one section, so the name is not important
; Set output path to the installation directory. ; Set output path to the installation directory.
SetOutPath $INSTDIR SetOutPath $INSTDIR
; Put file there ; Put file there
File ..\makensisw.exe File ..\makensisw.exe
SectionEnd ; end the section
SectionEnd ; end the section
; eof

View file

@ -1,10 +1,11 @@
; example2.nsi ; example2.nsi
; ;
; This script is based on example1.nsi, but adds uninstall support ; This script is based on example1.nsi, but it remember the directory,
; and (optionally) start menu shortcuts. ; has uninstall support and (optionally) installs start menu shortcuts.
;
; It will install notepad.exe into a directory that the user selects,
; ;
; It will install makensisw.exe into a directory that the user selects,
;--------------------------------
; The name of the installer ; The name of the installer
Name "Example2" Name "Example2"
@ -14,55 +15,72 @@ OutFile "example2.exe"
; The default installation directory ; The default installation directory
InstallDir $PROGRAMFILES\Example2 InstallDir $PROGRAMFILES\Example2
; Registry key to check for directory (so if you install again, it will ; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically) ; overwrite the old one automatically)
InstallDirRegKey HKLM SOFTWARE\NSIS_Example2 "Install_Dir" InstallDirRegKey HKLM SOFTWARE\NSIS_Example2 "Install_Dir"
; The text to prompt the user to enter a directory ; The text to prompt the user to enter a directory
ComponentText "This will install the less simple example2 on your computer. Select which optional things you want installed." ComponentText "This will install the less simple example2 on your computer. Select which optional things you want installed."
; The text to prompt the user to enter a directory ; The text to prompt the user to enter a directory
DirText "Choose a directory to install in to:" DirText "Choose a directory to install in to:"
;--------------------------------
; The stuff to install ; The stuff to install
Section "Example2 (required)" Section "Example2 (required)"
SectionIn RO SectionIn RO
; Set output path to the installation directory. ; Set output path to the installation directory.
SetOutPath $INSTDIR SetOutPath $INSTDIR
; Put file there ; Put file there
File "..\makensisw.exe" File "..\makensisw.exe"
; Write the installation path into the registry ; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\NSIS_Example2 "Install_Dir" "$INSTDIR" WriteRegStr HKLM SOFTWARE\NSIS_Example2 "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows ; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "DisplayName" "NSIS Example2 (remove only)" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "DisplayName" "NSIS Example2 (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteUninstaller "uninstall.exe" WriteUninstaller "uninstall.exe"
SectionEnd SectionEnd
; optional section ; optional section (can be disabled by the user)
Section "Start Menu Shortcuts" Section "Start Menu Shortcuts"
CreateDirectory "$SMPROGRAMS\Example2" CreateDirectory "$SMPROGRAMS\Example2"
CreateShortCut "$SMPROGRAMS\Example2\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 CreateShortCut "$SMPROGRAMS\Example2\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\Example2\Example2 (notepad).lnk" "$WINDIR\notepad.exe" "" "$INSTDIR\makensisw.exe" 0 CreateShortCut "$SMPROGRAMS\Example2\Example2 (MakeNSISW).lnk" "$INSTDIR\makensisw.exe" "" "$INSTDIR\makensisw.exe" 0
SectionEnd SectionEnd
; uninstall stuff ;--------------------------------
; Uninstaller
UninstallText "This will uninstall example2. Hit next to continue." UninstallText "This will uninstall example2. Hit next to continue."
; special uninstall section. ; Uninstall section
Section "Uninstall" Section "Uninstall"
; remove registry keys ; remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2"
DeleteRegKey HKLM SOFTWARE\NSIS_Example2 DeleteRegKey HKLM SOFTWARE\NSIS_Example2
; remove files
; remove files and uninstaller
Delete $INSTDIR\makensisw.exe Delete $INSTDIR\makensisw.exe
; MUST REMOVE UNINSTALLER, too
Delete $INSTDIR\uninstall.exe Delete $INSTDIR\uninstall.exe
; remove shortcuts, if any.
; remove shortcuts, if any
Delete "$SMPROGRAMS\Example2\*.*" Delete "$SMPROGRAMS\Example2\*.*"
; remove directories used.
; remove directories used
RMDir "$SMPROGRAMS\Example2" RMDir "$SMPROGRAMS\Example2"
RMDir "$INSTDIR" RMDir "$INSTDIR"
SectionEnd
; eof SectionEnd

View file

@ -4,7 +4,8 @@
; graphic related additions introduced in NSIS 2 ; graphic related additions introduced in NSIS 2
; ;
; Written by Amir Szkeley 22nd July 2002 ; Written by Amir Szkeley 22nd July 2002
;
;--------------------------------
!macro BIMAGE IMAGE PARMS !macro BIMAGE IMAGE PARMS
Push $0 Push $0
@ -15,6 +16,8 @@
Pop $0 Pop $0
!macroend !macroend
;--------------------------------
Name "Graphical effects" Name "Graphical effects"
OutFile "gfx.exe" OutFile "gfx.exe"
@ -44,6 +47,21 @@ Page custom customPage
Page directory dirImage Page directory dirImage
Page instfiles instImage Page instfiles instImage
; Install dir
InstallDir "${NSISDIR}\Examples"
;--------------------------------
Section ""
; You can also use the BI_NEXT macro here...
MessageBox MB_YESNO "We can change the branding image from within a section too!$\nDo you want me to change it?" IDNO done
!insertmacro BIMAGE "${NSISDIR}\Contrib\Icons\checksX2.bmp" ""
done:
WriteUninstaller uninst.exe
SectionEnd
;--------------------------------
Function licenseImage Function licenseImage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Icons\checks1.bmp" /RESIZETOFIT !insertmacro BIMAGE "${NSISDIR}\Contrib\Icons\checks1.bmp" /RESIZETOFIT
MessageBox MB_YESNO 'Would you like to skip the license page?' IDNO no MessageBox MB_YESNO 'Would you like to skip the license page?' IDNO no
@ -65,21 +83,10 @@ Function instImage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Icons\checks-sdbarker.bmp" /RESIZETOFIT !insertmacro BIMAGE "${NSISDIR}\Contrib\Icons\checks-sdbarker.bmp" /RESIZETOFIT
FunctionEnd FunctionEnd
; Install dir ;--------------------------------
InstallDir "${NSISDIR}\Examples"
Section
; You can also use the BI_NEXT macro here...
MessageBox MB_YESNO "We can change the branding image from within a section too!$\nDo you want me to change it?" IDNO done
!insertmacro BIMAGE "${NSISDIR}\Contrib\Icons\checksX2.bmp" ""
done:
WriteUninstaller uninst.exe
SectionEnd
; Another page for uninstaller
UninstallText "Another page..."
; Uninstall pages ; Uninstall pages
UninstPage uninstConfirm un.uninstImage UninstPage uninstConfirm un.uninstImage
UninstPage custom un.customPage UninstPage custom un.customPage
UninstPage instfiles un.instImage UninstPage instfiles un.instImage
@ -98,6 +105,14 @@ Function un.instImage
!insertmacro BIMAGE "${NSISDIR}\Contrib\Icons\jarsonic-checks.bmp" /RESIZETOFIT !insertmacro BIMAGE "${NSISDIR}\Contrib\Icons\jarsonic-checks.bmp" /RESIZETOFIT
FunctionEnd FunctionEnd
;--------------------------------
; Uninstaller
; Another page for uninstaller
UninstallText "Another page..."
Section uninstall Section uninstall
MessageBox MB_OK "Bla" MessageBox MB_OK "Bla"
SectionEnd SectionEnd

View file

@ -1,7 +1,16 @@
; languages.nsi
;
; This is an example of a multilingual installer
; The user can select the language on startup
;--------------------------------
OutFile languages.exe OutFile languages.exe
XPStyle on XPStyle on
;--------------------------------
; First is default ; First is default
LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf" LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf"
Name English Name English
@ -63,6 +72,8 @@ LangString Message ${LANG_TRADCHINESE} "Trandional Chinese message"
LangString Message ${LANG_SIMPCHINESE} "Simplified Chinese message" LangString Message ${LANG_SIMPCHINESE} "Simplified Chinese message"
LangString Message ${LANG_SLOVAK} "Slovak message" LangString Message ${LANG_SLOVAK} "Slovak message"
;--------------------------------
;Section names set by Language strings ;Section names set by Language strings
;It works with ! too ;It works with ! too
Section !$(Sec1Name) sec1 Section !$(Sec1Name) sec1
@ -94,7 +105,12 @@ Section "Section number two"
MessageBox MB_OK "Installing Slovak stuff" MessageBox MB_OK "Installing Slovak stuff"
SectionEnd SectionEnd
;--------------------------------
Function .onInit Function .onInit
;Language selection dialog
Push "" Push ""
Push ${LANG_ENGLISH} Push ${LANG_ENGLISH}
Push English Push English

View file

@ -1,3 +1,10 @@
; primes.nsi
;
; This is an example of the possibities of the NSIS Script language.
; It calculates prime numbers.
;--------------------------------
Name "primes" Name "primes"
AllowRootDirInstall true AllowRootDirInstall true
OutFile "primes.exe" OutFile "primes.exe"
@ -7,13 +14,19 @@ AllowRootDirInstall true
InstallDir "$EXEDIR" InstallDir "$EXEDIR"
DirText "Select directory to write primes.txt" DirText "Select directory to write primes.txt"
Section "crap" ;--------------------------------
Section ""
SetOutPath $INSTDIR SetOutPath $INSTDIR
Call DoPrimes Call DoPrimes
SectionEnd SectionEnd
;--------------------------------
Function DoPrimes Function DoPrimes
; we put this in here so it doesn't update the progress bar (faster) ; we put this in here so it doesn't update the progress bar (faster)
!define PPOS $0 ; position in prime searching !define PPOS $0 ; position in prime searching
!define PDIV $1 ; divisor !define PDIV $1 ; divisor
!define PMOD $2 ; the result of the modulus !define PMOD $2 ; the result of the modulus
@ -44,5 +57,5 @@ outerloop:
Goto outerloop Goto outerloop
stop: stop:
FileClose $9 FileClose $9
FunctionEnd
FunctionEnd

View file

@ -3,7 +3,8 @@
; This script creates a silent installer which extracts one (or more) HTML ; This script creates a silent installer which extracts one (or more) HTML
; files to a temporary directory, opens Internet Explorer to view the file(s), ; files to a temporary directory, opens Internet Explorer to view the file(s),
; and when Internet Explorer has quit, deletes the file(s). ; and when Internet Explorer has quit, deletes the file(s).
;
;--------------------------------
; The name of the installer (not really used in a silent install) ; The name of the installer (not really used in a silent install)
Name "ViewHTML" Name "ViewHTML"
@ -14,26 +15,21 @@ SilentInstall silent
; The file to write ; The file to write
OutFile "viewhtml.exe" OutFile "viewhtml.exe"
;--------------------------------
; The stuff to install ; The stuff to install
Section "" Section ""
; Set output path to the installation directory.
; Get a temporary filename (in the Windows Temp directory)
GetTempFileName $R0 GetTempFileName $R0
; Extract file ; Extract file
File /oname=$R0 "..\Docs\Chapter1.html" File /oname=$R0 "..\Docs\Chapter1.html"
; View file ; View file
ExecWait '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "$R0"' ; ExecShell "open" '"$R0"'
; Delete the files
Delete $R0 ; Delete the files (on reboot if file is in use)
SectionEnd Delete /REBOOTOK $R0
; Note: another way of doing this would be to use ExecShell, but then you SectionEnd
; really couldn't get away with deleting the files. Here is the ExecShell
; line that you would want to use:
;
; ExecShell "open" '"$R0"'
;
; The advantage of this way is that it would use the default browser to
; open the HTML.
;
; eof

View file

@ -1,12 +1,16 @@
; waplugin.nsi ; waplugin.nsi
; ;
; This script will generate an installer that installs a Winamp plug-in. ; This script will generate an installer that installs a Winamp 2 plug-in.
; It also puts a license page on, for shits and giggles. ; It also puts a license page on, for shits and giggles.
; ;
; This installer will automatically alert the user that installation was ; This installer will automatically alert the user that installation was
; successful, and ask them whether or not they would like to make the ; successful, and ask them whether or not they would like to make the
; plug-in the default and run Winamp. ; plug-in the default and run Winamp.
;
;--------------------------------
; Uncomment the next line to enable auto Winamp download
; !define WINAMP_AUTOINSTALL
; The name of the installer ; The name of the installer
Name "TinyVis Plug-in" Name "TinyVis Plug-in"
@ -14,13 +18,9 @@ Name "TinyVis Plug-in"
; The file to write ; The file to write
OutFile "waplugin.exe" OutFile "waplugin.exe"
; License page
; LicenseText "This installer will install the Nullsoft Tiny Visualization 2000 Plug-in for Winamp. Please read the license below."
; use the default makensis license :)
; LicenseData license.txt
; The default installation directory ; The default installation directory
InstallDir $PROGRAMFILES\Winamp InstallDir $PROGRAMFILES\Winamp
; detect winamp path from uninstall string if available ; detect winamp path from uninstall string if available
InstallDirRegKey HKLM \ InstallDirRegKey HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" \ "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" \
@ -32,30 +32,69 @@ DirShow hide
; automatically close the installer when done. ; automatically close the installer when done.
AutoCloseWindow true AutoCloseWindow true
; hide the "show details" box ; hide the "show details" box
ShowInstDetails nevershow ShowInstDetails nevershow
;--------------------------------
; The stuff to install
Section ""
!ifdef WINAMP_AUTOINSTALL
Call MakeSureIGotWinamp
!endif
Call QueryWinampVisPath
SetOutPath $1
; File to extract
File "C:\program files\winamp\plugins\vis_nsfs.dll"
; prompt user, and if they select no, go to NoWinamp
MessageBox MB_YESNO|MB_ICONQUESTION \
"The plug-in was installed. Would you like to run Winamp now with TinyVis as the default plug-in?" \
IDNO NoWinamp
WriteINIStr "$INSTDIR\Winamp.ini" "Winamp" "visplugin_name" "vis_nsfs.dll"
WriteINIStr "$INSTDIR\Winamp.ini" "Winamp" "visplugin_num" "0"
Exec '"$INSTDIR\Winamp.exe"'
NoWinamp:
SectionEnd
;--------------------------------
Function .onVerifyInstDir Function .onVerifyInstDir
!ifndef WINAMP_AUTOINSTALL !ifndef WINAMP_AUTOINSTALL
;Check for Winamp installation
IfFileExists $INSTDIR\Winamp.exe Good IfFileExists $INSTDIR\Winamp.exe Good
Abort Abort
Good: Good:
!endif ; WINAMP_AUTOINSTALL !endif ; WINAMP_AUTOINSTALL
FunctionEnd FunctionEnd
Function QueryWinampVisPath ; sets $1 with vis path Function QueryWinampVisPath ; sets $1 with vis path
StrCpy $1 $INSTDIR\Plugins StrCpy $1 $INSTDIR\Plugins
; use DSPDir instead of VISDir to get DSP plugins directory ; use DSPDir instead of VISDir to get DSP plugins directory
ReadINIStr $9 $INSTDIR\winamp.ini Winamp VisDir ReadINIStr $9 $INSTDIR\winamp.ini Winamp VisDir
StrCmp $9 "" End StrCmp $9 "" End
IfFileExists $9 0 End IfFileExists $9 0 End
StrCpy $1 $9 ; update dir StrCpy $1 $9 ; update dir
End: End:
FunctionEnd FunctionEnd
!ifdef WINAMP_AUTOINSTALL !ifdef WINAMP_AUTOINSTALL
Function GetWinampInstPath Function GetWinampInstPath
Push $0 Push $0
Push $1 Push $1
Push $2 Push $2
@ -96,16 +135,21 @@ Function GetWinampInstPath
Pop $2 Pop $2
Pop $1 Pop $1
Exch $0 Exch $0
FunctionEnd FunctionEnd
Function MakeSureIGotWinamp Function MakeSureIGotWinamp
Call GetWinampInstPath Call GetWinampInstPath
Pop $0 Pop $0
StrCmp $0 "" getwinamp StrCmp $0 "" getwinamp
Return Return
getwinamp: getwinamp:
Call ConnectInternet ;Make an internet connection (if no connection available)
StrCpy $2 "$TEMP\Winamp Installer.exe" StrCpy $2 "$TEMP\Winamp Installer.exe"
NSISdl::download http://download.nullsoft.com/winamp/client/winamp281_lite.exe $2 NSISdl::download http://download.nullsoft.com/winamp/client/winamp281_lite.exe $2
Pop $0 Pop $0
@ -121,29 +165,27 @@ Function MakeSureIGotWinamp
StrCmp $0 "" skip StrCmp $0 "" skip
StrCpy $INSTDIR $0 StrCpy $INSTDIR $0
skip: skip:
FunctionEnd FunctionEnd
!endif ; WINAMP_AUTOINSTALL Function ConnectInternet
; The stuff to install
Section "ThisNameIsIgnoredSoWhyBother?" ClearErrors
!ifdef WINAMP_AUTOINSTALL Dialer::AttemptConnect
Call MakeSureIGotWinamp IfErrors noie3
!endif
Pop $R0
StrCmp $R0 "online" connected
MessageBox MB_OK|MB_ICONSTOP "Cannot connect to the internet."
Quit
noie3:
; IE3 not installed
MessageBox MB_OK|MB_ICONINFORMATION "Please connect to the internet now."
connected:
FunctionEnd
Call QueryWinampVisPath !endif ; WINAMP_AUTOINSTALL
SetOutPath $1
; File to extract
File "C:\program files\winamp\plugins\vis_nsfs.dll"
; prompt user, and if they select no, skip the following 3 instructions.
MessageBox MB_YESNO|MB_ICONQUESTION \
"The plug-in was installed. Would you like to run Winamp now with TinyVis as the default plug-in?" \
IDNO NoWinamp
WriteINIStr "$INSTDIR\Winamp.ini" "Winamp" "visplugin_name" "vis_nsfs.dll"
WriteINIStr "$INSTDIR\Winamp.ini" "Winamp" "visplugin_num" "0"
Exec '"$INSTDIR\Winamp.exe"'
NoWinamp:
SectionEnd
; eof