home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / nastroje / d23456 / NSIS.EXE / bigtest.nsi next >
Text File  |  2001-05-19  |  7KB  |  231 lines

  1. ; bigtest.nsi
  2. ;
  3. ; This script attempts to test most of the functionality of NSIS.
  4. ;
  5. !ifdef HAVE_UPX
  6. !packhdr tmp.dat "upx\upx -9 tmp.dat"
  7. !endif
  8.  
  9. !ifdef NOCOMPRESS
  10. SetCompress off
  11. !endif
  12.  
  13. SetDateSave on
  14. SetDatablockOptimize on
  15. CRCCheck on
  16. SilentInstall normal
  17. BGGradient 000000 800000 FFFFFF
  18. InstallColors FF8080 000030
  19.  
  20.  
  21. Name "BigNSISTest"
  22. Caption "NSIS Big Test"
  23. Icon "main.ico"
  24. OutFile "bigtest.exe"
  25.  
  26. LicenseText "make sure this license text is all there (it's about 28k last I checked). The last line is a simple '}'."
  27. LicenseData "source\exehead\ui.c"
  28.  
  29. InstallDir "$PROGRAMFILES\NSISCrap\BigNSISTest"
  30. InstallDirRegKey HKLM SOFTWARE\NSISCrap\BigNSISTest "Install_Dir"
  31. DirText "Choose a directory to install in to:"
  32.  
  33. ; uninstall stuff
  34. UninstallText "This will uninstall example2. Hit next to continue."
  35. UninstallExeName "bt-uninst.exe"
  36. UninstallIcon "uninst.ico"
  37.  
  38. ComponentText "This will install the test on your computer. Select which optional things you want installed."
  39. EnabledBitmap bitmap1.bmp
  40. DisabledBitmap bitmap2.bmp
  41. !ifndef NOINSTTYPES ; only if not defined
  42. InstType "Most"
  43. InstType "Full"
  44. InstType "More"
  45. InstType "Base"
  46. ;InstType /NOCUSTOM
  47. !endif
  48.  
  49. AutoCloseWindow false
  50. ShowInstDetails show
  51.  
  52.  
  53. Section "" ; empty string makes it hidden, so would starting with -
  54. ; write reg crap
  55. StrCpy $1 "POOOOOOOOOOOP"
  56. DetailPrint "I like to f*ck sheep $1"
  57. WriteRegStr HKLM SOFTWARE\NSISCrap\BigNSISTest "Install_Dir" "$INSTDIR"
  58. ; write uninstall strings
  59. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest" "DisplayName" "BigNSISTest (remove only)"
  60. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest" "UninstallString" '"$INSTDIR\bt-uninst.exe"'
  61. File /oname=poop.exe C:\windows\notepad.exe
  62.  
  63. SetOutPath $INSTDIR
  64. File "source\exehead\bin2h.exe"
  65. CreateDirectory "$INSTDIR\shiz\crap" ; 2 recursively create a directory for fun.
  66. Nop ; for fun
  67. SectionEnd
  68.  
  69. Section "TempTest"
  70. SectionIn 123
  71.   Start: MessageBox MB_OK "Start:"
  72.  
  73.   MessageBox MB_YESNO "Goto Poop" IDYES Poop
  74.  
  75.   MessageBox MB_OK "Right before Poop:"
  76.  
  77.   Poop: MessageBox MB_OK "Poop:"
  78.   
  79.   MessageBox MB_OK "Right after Poop:"
  80.  
  81.   MessageBox MB_YESNO "Goto Start:?" IDYES Start
  82.  
  83. SectionEnd
  84.  
  85.  
  86.  
  87.  
  88. Function poopTest
  89. ReadINIStr $1 "$INSTDIR\test.ini" "MySectionShit" "Value1"
  90. StrCmp $1 $8 NoFailedMsg
  91.   MessageBox MB_OK "WriteINIStr failed"
  92. NoFailedMsg: FunctionEnd 
  93.  
  94.  
  95. Section "Test Registry/INI functions"
  96. SectionIn 123
  97. WriteRegStr HKLM SOFTWARE\NSISCrap\BigNSISTest "StrTest_INSTDIR" "$INSTDIR"
  98. WriteRegDword HKLM SOFTWARE\NSISCrap\BigNSISTest "DwordTest_0xDEADBEEF" 0xdeadbeef
  99. WriteRegDword HKLM SOFTWARE\NSISCrap\BigNSISTest "DwordTest_123456" 123456
  100. WriteRegDword HKLM SOFTWARE\NSISCrap\BigNSISTest "DwordTest_0123" 0123
  101. WriteRegBin HKLM SOFTWARE\NSISCrap\BigNSISTest "BinTest_deadbeef01f00dbeef" "DEADBEEF01F00DBEEF"
  102. StrCpy $8 "$SYSDIR\Poop"
  103. WriteINIStr "$INSTDIR\test.ini"  "MySection" "Value1" $8
  104. WriteINIStr "$INSTDIR\test.ini"  "MySectionShit" "Value1" $8
  105. WriteINIStr "$INSTDIR\test.ini"  "MySectionShit" "Value2" $8
  106. WriteINIStr "$INSTDIR\test.ini"  "POOPon" "Value1" $8
  107. Call poopTest
  108.  
  109. DeleteINIStr "$INSTDIR\test.ini" "POOPon" "Value1"
  110. DeleteINISec "$INSTDIR\test.ini" "MySectionShit"
  111.  
  112. ReadINIStr $1 "$INSTDIR\test.ini" "MySectionShit" "Value1"
  113. StrCmp $1 "" INIDelSuccess
  114.   MessageBox MB_OK "DeleteINISec failed"
  115. INIDelSuccess:
  116.  
  117. ClearErrors
  118. ReadRegStr $1 HKCR "software\microsoft" shit
  119. IfErrors 0 NoError
  120.   MessageBox MB_OK "could not read from HKCR\software\microsoft\shit"
  121.   Goto ErrorYay
  122. NoError:
  123.   MessageBox MB_OK "read '$1' from HKCR\software\microsoft\shit"
  124. ErrorYay:
  125. SectionEnd
  126.  
  127.  
  128. Function "CSCTest"
  129. CreateDirectory "$SMPROGRAMS\Big NSIS Test"
  130. SetOutPath $INSTDIR ; for working directory
  131. CreateShortCut "$SMPROGRAMS\Big NSIS Test\Uninstall BIG NSIS Test.lnk" "$INSTDIR\bt-uninst.exe" ; use defaults for parameters, icon, etc.
  132. ; this one will use notepad's icon, start it minimized, and give it a hotkey (of Ctrl+Shift+Q)
  133. CreateShortCut "$SMPROGRAMS\Big NSIS Test\bin2h.exe.lnk" "$INSTDIR\bin2h.exe" "" "$WINDIR\notepad.exe" 0 SW_SHOWMINIMIZED CONTROL|SHIFT|Q
  134. CreateShortCut "$SMPROGRAMS\Big NSIS Test\TheDir.lnk" "$INSTDIR\" "" "" 0 SW_SHOWMAXIMIZED CONTROL|SHIFT|Z
  135. FunctionEnd
  136.  
  137. Section "Test CreateShortCut"
  138. SectionIn 123
  139. Call CSCTest
  140. SectionEnd
  141.  
  142. Function myfunc
  143. StrCpy $2 "poop=$1"
  144. MessageBox MB_OK "myfunc: $2"
  145. FunctionEnd
  146.  
  147. Section "Test Branching"
  148. BeginTestSection:
  149. SectionIn 123
  150. SetOutPath $INSTDIR
  151. IfFileExists "$INSTDIR\bin2h.c" 0 BranchTest69
  152.   MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to overwrite $INSTDIR\bin2h.c?" IDNO NoOverwrite ; skipped if file doesn't exist
  153. BranchTest69:
  154.   SetOverwrite ifnewer ; NOT AN INSTRUCTION, NOT COUNTED IN SKIPPINGS
  155. NoOverwrite:
  156. File "source\exehead\bin2h.c" ; skipped if answered no
  157. SetOverwrite try ; NOT AN INSTRUCTION, NOT COUNTED IN SKIPPINGS
  158. MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to skip the rest of this section?" IDYES EndTestBranch
  159. MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to go back to the beginning of this section?" IDYES BeginTestSection
  160. MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to hide the installer and wait five seconds?" IDNO NoHide
  161. HideWindow
  162. Sleep 5000
  163. BringToFront
  164. NoHide:
  165. MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to call the function 5 times?" IDNO NoRecurse
  166. StrCpy $1 "x"
  167. LoopPoop: 
  168.   Call myfunc
  169.   StrCpy $1 "x$1"
  170.   StrCmp $1 "xxxxxx" 0 LoopPoop
  171. NoRecurse:
  172.  
  173. EndTestBranch:
  174.  
  175. SectionEnd
  176.  
  177. Section "Test CopyFiles"
  178. SectionIn 123
  179. SetOutPath $INSTDIR\cpdest
  180. CopyFiles "$WINDIR\*.ini" "$INSTDIR\cpdest" 0
  181. SectionEnd
  182.  
  183. Section "Test Exec functions"
  184. SectionIn 123
  185. GetFullDLLPath $1 notepad.exe
  186. MessageBox MB_OK "notepad.exe=$1"
  187. Exec '"$1"'
  188. ExecShell "open" '"$INSTDIR"'
  189. Sleep 500
  190. BringToFront
  191. SectionEnd
  192.  
  193. Section "Test Netscape Plug-in Installing"
  194. SectionIn 2
  195. ; I don't have a real netscape plug-in, so I'll just have it put, uhh, makensis.exe into those directories.
  196. InstNSPlug "makensis.exe"
  197. SectionEnd
  198.  
  199. Section "Test ActiveX control registration"
  200. SectionIn 2
  201. UnRegDLL "$SYSDIR\spin32.ocx"
  202. Sleep 1000
  203. RegDLL "$SYSDIR\spin32.ocx"
  204. Sleep 1000
  205. SectionEnd
  206.  
  207. ; special uninstall section.
  208. Section "Uninstall"
  209. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest"
  210. DeleteRegKey HKLM "SOFTWARE\NSISCrap\BigNSISTest"
  211. DeleteNSPlug "makensis.exe"
  212. Delete "$INSTDIR\bin2h.exe"
  213. Delete "$INSTDIR\bin2h.c"
  214. Delete "$INSTDIR\bt-uninst.exe"
  215. Delete "$INSTDIR\test.ini"
  216. Delete "$SMPROGRAMS\Big NSIS Test\*.*"
  217. RMDir "$SMPROGRAMS\BiG NSIS Test"
  218. MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to remove the directory $INSTDIR\cpdest?" IDNO NoDelete
  219. Delete "$INSTDIR\cpdest\*.*"
  220. RMDir "$INSTDIR\cpdest" ; skipped if no
  221. NoDelete:
  222. RMDir "$INSTDIR\shiz\crap"
  223. RMDir "$INSTDIR\shiz"
  224. RMDir "$INSTDIR"
  225. IfFileExists "$INSTDIR" 0 NoErrorMsg
  226. MessageBox MB_OK "Note: $INSTDIR could not be removed!" IDOK 0 ; skipped if file doesn't exist
  227. NoErrorMsg:
  228. SectionEnd
  229.  
  230. ; eof
  231.