installer.nsi 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
  1. ; Panda3D installation script for the Nullsoft Installation System (NSIS).
  2. ; Jon Parise <[email protected]>
  3. ; with Ben Johnson <[email protected]>
  4. ; with Jason Pratt <[email protected]>
  5. ; mangled by Josh Yelon <[email protected]>
  6. ; Heavily restructured by rdb
  7. ; Caller needs to define these variables:
  8. ;
  9. ; COMPRESSOR - either zlib or lzma
  10. ; TITLE - title (eg. "Panda3D SDK 1.9.0")
  11. ; INSTALLDIR - default install location (eg. "C:\Panda3D-1.9.0-x64")
  12. ; OUTFILE - where to put the output file (eg. "..\nsis-output.exe")
  13. ;
  14. ; BUILT - location of panda install tree.
  15. ; SOURCE - location of the panda source-tree if available, OR location of panda install tree.
  16. ; PYVER - version of Python that Panda was built with (ie, "2.7")
  17. ; PYEXTRAS - directory containing python extras, if any.
  18. ; REGVIEW - either 32 or 64, depending on the build architecture.
  19. ;
  20. Name "${TITLE}"
  21. InstallDir "${INSTALLDIR}"
  22. OutFile "${OUTFILE}"
  23. RequestExecutionLevel user
  24. SetCompress auto
  25. SetCompressor ${COMPRESSOR}
  26. !include "MUI2.nsh"
  27. !include "Sections.nsh"
  28. !include "WinMessages.nsh"
  29. !include "WordFunc.nsh"
  30. !define MUI_WELCOMEFINISHPAGE_BITMAP "panda-install.bmp"
  31. !define MUI_UNWELCOMEFINISHPAGE_BITMAP "panda-install.bmp"
  32. !define MUI_ABORTWARNING
  33. !define MUI_FINISHPAGE_NOREBOOTSUPPORT
  34. !define MUI_FINISHPAGE_RUN
  35. !define MUI_FINISHPAGE_RUN_FUNCTION runFunction
  36. !define MUI_FINISHPAGE_RUN_TEXT "Visit the Panda3D Manual"
  37. !insertmacro MUI_PAGE_WELCOME
  38. !insertmacro MUI_PAGE_LICENSE "../doc/LICENSE"
  39. !insertmacro MUI_PAGE_DIRECTORY
  40. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE ConfirmPythonSelection
  41. !insertmacro MUI_PAGE_COMPONENTS
  42. !insertmacro MUI_PAGE_INSTFILES
  43. !insertmacro MUI_PAGE_FINISH
  44. !insertmacro MUI_UNPAGE_WELCOME
  45. !insertmacro MUI_UNPAGE_CONFIRM
  46. !insertmacro MUI_UNPAGE_INSTFILES
  47. !insertmacro MUI_UNPAGE_FINISH
  48. !insertmacro MUI_LANGUAGE "English"
  49. ShowInstDetails hide
  50. ShowUninstDetails hide
  51. LicenseData "${LICENSE}"
  52. InstType "Full (Recommended)"
  53. InstType "Minimal"
  54. LangString DESC_SecCore ${LANG_ENGLISH} "The Panda3D core libraries, configuration files and models/textures that are needed to use Panda3D."
  55. LangString DESC_SecOpenGL ${LANG_ENGLISH} "The OpenGL graphics back-end is the most well-supported renderer."
  56. LangString DESC_SecDirect3D9 ${LANG_ENGLISH} "The optional Direct3D 9 renderer."
  57. LangString DESC_SecOpenAL ${LANG_ENGLISH} "Support for playing audio via the OpenAL library. You need either OpenAL or FMOD to be able to play audio."
  58. LangString DESC_SecFMOD ${LANG_ENGLISH} "Support for decoding and playing audio via the FMOD Ex library. You need either OpenAL or FMOD to be able to play audio."
  59. LangString DESC_SecFFMpeg ${LANG_ENGLISH} "Support for decoding video and audio via the FFMpeg library. Without this option, Panda3D will only be able to play .wav and .ogg audio files."
  60. LangString DESC_SecBullet ${LANG_ENGLISH} "Support for the Bullet physics engine."
  61. LangString DESC_SecODE ${LANG_ENGLISH} "Support for the Open Dynamics Engine to implement physics."
  62. LangString DESC_SecPhysX ${LANG_ENGLISH} "Support for NVIDIA PhysX to implement physics."
  63. LangString DESC_SecRocket ${LANG_ENGLISH} "Support for the libRocket GUI library. This is an optional library that offers an HTML/CSS-like approach to creating user interfaces."
  64. LangString DESC_SecTools ${LANG_ENGLISH} "Useful tools and model converters to help with Panda3D development. Recommended."
  65. LangString DESC_SecPyBindings ${LANG_ENGLISH} "Contains the Python modules that allow use of Panda3D using Python. These will only work with a ${REGVIEW}-bit version of Python ${PYVER}."
  66. LangString DESC_SecPython ${LANG_ENGLISH} "Contains a ${REGVIEW}-bit copy of Python ${PYVER} preconfigured to make use of Panda3D."
  67. LangString DESC_SecHeadersLibs ${LANG_ENGLISH} "Headers and libraries needed for C++ development with Panda3D."
  68. LangString DESC_SecSamples ${LANG_ENGLISH} "The sample programs demonstrate how to make Python applications with Panda3D."
  69. LangString DESC_SecMaxPlugins ${LANG_ENGLISH} "Plug-ins for Autodesk 3ds Max (${REGVIEW}-bit) that can be used to export models to Panda3D."
  70. LangString DESC_SecMayaPlugins ${LANG_ENGLISH} "Plug-ins and scripts for Autodesk Maya (${REGVIEW}-bit) that can be used to export models to Panda3D."
  71. var READABLE
  72. var MANPAGE
  73. ; See http://nsis.sourceforge.net/Check_if_a_file_exists_at_compile_time for documentation
  74. !macro !defineifexist _VAR_NAME _FILE_NAME
  75. !tempfile _TEMPFILE
  76. !ifdef NSIS_WIN32_MAKENSIS
  77. ; Windows - cmd.exe
  78. !system 'if exist "${_FILE_NAME}" echo !define ${_VAR_NAME} > "${_TEMPFILE}"'
  79. !else
  80. ; Posix - sh
  81. !system 'if [ -e "${_FILE_NAME}" ]; then echo "!define ${_VAR_NAME}" > "${_TEMPFILE}"; fi'
  82. !endif
  83. !include '${_TEMPFILE}'
  84. !delfile '${_TEMPFILE}'
  85. !undef _TEMPFILE
  86. !macroend
  87. !insertmacro !defineifexist HAVE_GL "${BUILT}\bin\libpandagl.dll"
  88. !insertmacro !defineifexist HAVE_DX9 "${BUILT}\bin\libpandadx9.dll"
  89. !insertmacro !defineifexist HAVE_OPENAL "${BUILT}\bin\libp3openal_audio.dll"
  90. !insertmacro !defineifexist HAVE_FMOD "${BUILT}\bin\libp3fmod_audio.dll"
  91. !insertmacro !defineifexist HAVE_FFMPEG "${BUILT}\bin\libp3ffmpeg.dll"
  92. !insertmacro !defineifexist HAVE_BULLET "${BUILT}\bin\libpandabullet.dll"
  93. !insertmacro !defineifexist HAVE_ODE "${BUILT}\bin\libpandaode.dll"
  94. !insertmacro !defineifexist HAVE_PHYSX "${BUILT}\bin\libpandaphysx.dll"
  95. !insertmacro !defineifexist HAVE_ROCKET "${BUILT}\bin\libp3rocket.dll"
  96. !insertmacro !defineifexist HAVE_PYTHON "${BUILT}\python"
  97. !insertmacro !defineifexist HAVE_SAMPLES "${SOURCE}\samples"
  98. !insertmacro !defineifexist HAVE_MAX_PLUGINS "${BUILT}\plugins\*.dlo"
  99. !insertmacro !defineifexist HAVE_MAYA_PLUGINS "${BUILT}\plugins\*.mll"
  100. Function runFunction
  101. ExecShell "open" "$SMPROGRAMS\${TITLE}\Panda3D Manual.lnk"
  102. FunctionEnd
  103. SectionGroup "Panda3D Libraries"
  104. Section "Core Libraries" SecCore
  105. SectionIn 1 2 RO
  106. SetShellVarContext current
  107. SetOverwrite try
  108. SetDetailsPrint both
  109. DetailPrint "Installing Panda3D libraries..."
  110. SetDetailsPrint listonly
  111. SetOutPath "$INSTDIR"
  112. File "${BUILT}\LICENSE"
  113. File /r /x CVS "${BUILT}\ReleaseNotes"
  114. SetOutPath $INSTDIR\bin
  115. File /r /x libpandagl.dll /x libpandadx9.dll /x cgD3D*.dll /x python*.dll /x libpandaode.dll /x libp3fmod_audio.dll /x fmodex*.dll /x libp3ffmpeg.dll /x av*.dll /x postproc*.dll /x swscale*.dll /x swresample*.dll /x NxCharacter*.dll /x cudart*.dll /x PhysX*.dll /x libpandaphysx.dll /x libp3rocket.dll /x boost_python*.dll /x Rocket*.dll /x _rocket*.pyd /x libpandabullet.dll /x OpenAL32.dll /x *_oal.dll /x libp3openal_audio.dll "${BUILT}\bin\*.dll"
  116. File /nonfatal /r "${BUILT}\bin\Microsoft.*.manifest"
  117. SetOutPath $INSTDIR\etc
  118. File /r "${BUILT}\etc\*"
  119. SetDetailsPrint both
  120. DetailPrint "Installing models..."
  121. SetDetailsPrint listonly
  122. SetOutPath $INSTDIR\models
  123. File /r /x CVS "${BUILT}\models\*"
  124. RMDir /r "$SMPROGRAMS\${TITLE}"
  125. CreateDirectory "$SMPROGRAMS\${TITLE}"
  126. SectionEnd
  127. !ifdef HAVE_GL
  128. Section "OpenGL" SecOpenGL
  129. SectionIn 1 2 RO
  130. SetOutPath "$INSTDIR\bin"
  131. File "${BUILT}\bin\libpandagl.dll"
  132. SectionEnd
  133. !endif
  134. !ifdef HAVE_DX9
  135. Section "Direct3D 9" SecDirect3D9
  136. SectionIn 1
  137. SetOutPath "$INSTDIR\bin"
  138. File "${BUILT}\bin\libpandadx9.dll"
  139. File /nonfatal /r "${BUILT}\bin\cgD3D9.dll"
  140. SectionEnd
  141. !endif
  142. !ifdef HAVE_OPENAL
  143. Section "OpenAL Audio" SecOpenAL
  144. SectionIn 1 2
  145. SetOutPath "$INSTDIR\bin"
  146. File "${BUILT}\bin\libp3openal_audio.dll"
  147. File /nonfatal /r "${BUILT}\bin\OpenAL32.dll"
  148. File /nonfatal /r "${BUILT}\bin\*_oal.dll"
  149. SectionEnd
  150. !endif
  151. !ifdef HAVE_FMOD
  152. Section "FMOD Audio" SecFMOD
  153. SectionIn 1
  154. SetOutPath "$INSTDIR\bin"
  155. File "${BUILT}\bin\libp3fmod_audio.dll"
  156. File /r "${BUILT}\bin\fmodex*.dll"
  157. SectionEnd
  158. !endif
  159. !ifdef HAVE_FFMPEG
  160. Section "FFMpeg" SecFFMpeg
  161. SectionIn 1
  162. SetOutPath "$INSTDIR\bin"
  163. File "${BUILT}\bin\libp3ffmpeg.dll"
  164. File /nonfatal /r "${BUILT}\bin\av*.dll"
  165. File /nonfatal /r "${BUILT}\bin\swscale*.dll"
  166. File /nonfatal /r "${BUILT}\bin\swresample*.dll"
  167. File /nonfatal /r "${BUILT}\bin\postproc*.dll"
  168. SectionEnd
  169. !endif
  170. !ifdef HAVE_BULLET
  171. Section "Bullet Physics" SecBullet
  172. SectionIn 1
  173. SetOutPath "$INSTDIR\bin"
  174. File "${BUILT}\bin\libpandabullet.dll"
  175. SectionEnd
  176. !endif
  177. !ifdef HAVE_ODE
  178. Section "ODE Physics" SecODE
  179. SectionIn 1
  180. SetOutPath "$INSTDIR\bin"
  181. File "${BUILT}\bin\libpandaode.dll"
  182. SectionEnd
  183. !endif
  184. !ifdef HAVE_PHYSX
  185. Section "NVIDIA PhysX" SecPhysX
  186. SectionIn 1
  187. SetOutPath "$INSTDIR\bin"
  188. File "${BUILT}\bin\libpandaphysx.dll"
  189. File /nonfatal /r "${BUILT}\bin\PhysX*.dll"
  190. File /nonfatal /r "${BUILT}\bin\NxCharacter*.dll"
  191. File /nonfatal /r "${BUILT}\bin\cudart*.dll"
  192. SectionEnd
  193. !endif
  194. !ifdef HAVE_ROCKET
  195. Section "libRocket GUI" SecRocket
  196. SectionIn 1
  197. SetOutPath "$INSTDIR\bin"
  198. File "${BUILT}\bin\libp3rocket.dll"
  199. File /nonfatal /r "${BUILT}\bin\Rocket*.dll"
  200. File /nonfatal /r "${BUILT}\bin\_rocket*.pyd"
  201. File /nonfatal /r "${BUILT}\bin\boost_python*.dll"
  202. SectionEnd
  203. !endif
  204. SectionGroupEnd
  205. Section "Tools and utilities" SecTools
  206. SectionIn 1 2
  207. SetDetailsPrint both
  208. DetailPrint "Installing utilities..."
  209. SetDetailsPrint listonly
  210. SetOutPath "$INSTDIR\bin"
  211. File /r "${BUILT}\bin\*.exe"
  212. File /nonfatal /r "${BUILT}\bin\*.p3d"
  213. SetOutPath "$INSTDIR\NSIS"
  214. File /r /x CVS "${NSISDIR}\*"
  215. SectionEnd
  216. SectionGroup "Python support"
  217. Section "Python bindings" SecPyBindings
  218. SectionIn 1 2
  219. SetDetailsPrint both
  220. DetailPrint "Installing Panda3D Python modules..."
  221. SetDetailsPrint listonly
  222. SetOutPath "$INSTDIR\bin"
  223. File /nonfatal /r "${BUILT}\bin\*.pyd"
  224. SetOutPath $INSTDIR\direct\directscripts
  225. File /r /x CVS /x Opt?-Win32 "${BUILT}\direct\directscripts\*"
  226. SetOutPath $INSTDIR\direct\filter
  227. File /r /x CVS /x Opt?-Win32 "${BUILT}\direct\filter\*.sha"
  228. SetOutPath $INSTDIR\direct
  229. File /r /x CVS /x Opt?-Win32 "${BUILT}\direct\*.py"
  230. Delete "$INSTDIR\panda3d.py"
  231. Delete "$INSTDIR\panda3d.pyc"
  232. Delete "$INSTDIR\panda3d.pyo"
  233. SetOutPath $INSTDIR\pandac
  234. File /r "${BUILT}\pandac\*.py"
  235. SetOutPath $INSTDIR\panda3d
  236. File /r "${BUILT}\panda3d\*.py"
  237. File /r /x bullet.pyd /x ode.pyd /x physx.pyd /x rocket.pyd "${BUILT}\panda3d\*.pyd"
  238. !ifdef HAVE_BULLET
  239. SectionGetFlags ${SecBullet} $R0
  240. IntOp $R0 $R0 & ${SF_SELECTED}
  241. StrCmp $R0 ${SF_SELECTED} 0 SkipBulletPyd
  242. File /nonfatal /r "${BUILT}\panda3d\bullet.pyd"
  243. SkipBulletPyd:
  244. !endif
  245. !ifdef HAVE_ODE
  246. SectionGetFlags ${SecODE} $R0
  247. IntOp $R0 $R0 & ${SF_SELECTED}
  248. StrCmp $R0 ${SF_SELECTED} 0 SkipODEPyd
  249. File /nonfatal /r "${BUILT}\panda3d\ode.pyd"
  250. SkipODEPyd:
  251. !endif
  252. !ifdef HAVE_PHYSX
  253. SectionGetFlags ${SecPhysX} $R0
  254. IntOp $R0 $R0 & ${SF_SELECTED}
  255. StrCmp $R0 ${SF_SELECTED} 0 SkipPhysXPyd
  256. File /nonfatal /r "${BUILT}\panda3d\physx.pyd"
  257. SkipPhysXPyd:
  258. !endif
  259. !ifdef HAVE_ROCKET
  260. SectionGetFlags ${SecRocket} $R0
  261. IntOp $R0 $R0 & ${SF_SELECTED}
  262. StrCmp $R0 ${SF_SELECTED} 0 SkipRocketPyd
  263. File /nonfatal /r "${BUILT}\panda3d\rocket.pyd"
  264. SkipRocketPyd:
  265. !endif
  266. SetOutPath $INSTDIR\pandac\input
  267. File /r "${BUILT}\pandac\input\*"
  268. SetOutPath $INSTDIR\Pmw
  269. File /r /x CVS "${BUILT}\Pmw\*"
  270. !ifdef REGVIEW
  271. SetRegView ${REGVIEW}
  272. !endif
  273. ; Check for a system-wide Python installation.
  274. ; We could check for a user installation of Python as well, but there
  275. ; is no distinction between 64-bit and 32-bit regviews in HKCU, so we
  276. ; can't guess whether it might be a compatible version.
  277. ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" ""
  278. StrCmp $0 "$INSTDIR\python" SkipExternalPth 0
  279. StrCmp $0 "" SkipExternalPth 0
  280. IfFileExists "$0\ppython.exe" SkipExternalPth 0
  281. IfFileExists "$0\python.exe" 0 SkipExternalPth
  282. ; We're pretty sure this Python build is of the right architecture.
  283. MessageBox MB_YESNO|MB_ICONQUESTION \
  284. "Your system already has a copy of Python ${PYVER} installed in:$\r$\n$0$\r$\nWould you like to configure it to be able to use the Panda3D libraries?$\r$\nIf you choose no, you will only be able to use Panda3D's own copy of Python." \
  285. IDYES WriteExternalPth IDNO SkipExternalPth
  286. WriteExternalPth:
  287. FileOpen $1 "$0\Lib\site-packages\panda.pth" w
  288. FileWrite $1 "$INSTDIR$\r$\n"
  289. FileWrite $1 "$INSTDIR\bin$\r$\n"
  290. FileClose $1
  291. SkipExternalPth:
  292. SectionEnd
  293. !ifdef HAVE_PYTHON
  294. Section "Python ${PYVER}" SecPython
  295. SectionIn 1 2
  296. !ifdef REGVIEW
  297. SetRegView ${REGVIEW}
  298. !endif
  299. SetDetailsPrint both
  300. DetailPrint "Installing Python ${PYVER} (${REGVIEW}-bit)..."
  301. SetDetailsPrint listonly
  302. SetOutPath "$INSTDIR\bin"
  303. File /nonfatal "${BUILT}\bin\python*.dll"
  304. SetOutPath "$INSTDIR\python"
  305. File /r "${BUILT}\python\*"
  306. !ifdef PYEXTRAS
  307. SetOutPath "$INSTDIR\python\lib"
  308. File /nonfatal /r "${PYEXTRAS}\*"
  309. !endif
  310. SetDetailsPrint both
  311. DetailPrint "Adding registry keys for Python..."
  312. SetDetailsPrint listonly
  313. ; Check if a copy of Python is installed for this user.
  314. ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" ""
  315. StrCmp "$0" "$INSTDIR\python" RegPath 0
  316. StrCmp "$0" "" SkipFileCheck 0
  317. IfFileExists "$0\python.exe" AskRegPath 0
  318. SkipFileCheck:
  319. ; Check if a system-wide copy of Python is installed.
  320. ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" ""
  321. StrCmp "$0" "$INSTDIR\python" RegPath 0
  322. StrCmp "$0" "" RegPath 0
  323. IfFileExists "$0\python.exe" AskRegPath RegPath
  324. AskRegPath:
  325. MessageBox MB_YESNO|MB_ICONQUESTION \
  326. "You already have a copy of Python ${PYVER} installed in:$\r$\n$0$\r$\n$\r$\nPanda3D installs its own copy of Python ${PYVER}, which will install alongside your existing copy. Would you like to make Panda's copy the default Python for your user account?" \
  327. IDNO SkipRegPath
  328. RegPath:
  329. WriteRegStr HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" "" "$INSTDIR\python"
  330. SkipRegPath:
  331. SectionEnd
  332. !endif
  333. SectionGroupEnd
  334. Function ConfirmPythonSelection
  335. ; Check the current state of the "Python" section selection.
  336. SectionGetFlags ${SecPython} $R0
  337. IntOp $R1 $R0 & ${SF_SELECTED}
  338. ; Is the "Python" selection deselected?
  339. StrCmp $R1 ${SF_SELECTED} SkipCheck 0
  340. ; Maybe the user just doesn't want Python support at all?
  341. SectionGetFlags ${SecPyBindings} $R1
  342. IntOp $R1 $R1 & ${SF_SELECTED}
  343. StrCmp $R1 ${SF_SELECTED} 0 SkipCheck
  344. !ifdef REGVIEW
  345. SetRegView ${REGVIEW}
  346. !endif
  347. ; Check for a user installation of Python.
  348. ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" ""
  349. StrCmp $0 "$INSTDIR\python" CheckSystemWidePython 0
  350. StrCmp $0 "" CheckSystemWidePython 0
  351. IfFileExists "$0\ppython.exe" CheckSystemWidePython 0
  352. IfFileExists "$0\python.exe" SkipCheck CheckSystemWidePython
  353. ; Check for a system-wide Python installation.
  354. CheckSystemWidePython:
  355. ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" ""
  356. StrCmp $0 "$INSTDIR\python" AskConfirmation 0
  357. StrCmp $0 "" AskConfirmation 0
  358. IfFileExists "$0\ppython.exe" AskConfirmation 0
  359. IfFileExists "$0\python.exe" SkipCheck AskConfirmation
  360. ; No compatible Python version found (that wasn't shipped as part
  361. ; of a different Panda3D build.) Ask the user if he's sure about this.
  362. AskConfirmation:
  363. MessageBox MB_YESNO|MB_ICONQUESTION \
  364. "You do not appear to have a ${REGVIEW}-bit version of Python ${PYVER} installed. Are you sure you don't want Panda to install a compatible copy of Python?$\r$\n$\r$\nIf you choose Yes, you will not be able to do Python development with Panda3D until you install a ${REGVIEW}-bit version of Python ${PYVER} and manually configure it to be able to use Panda3D." \
  365. IDYES SkipCheck
  366. ; User clicked no, so re-enable the select box and abort.
  367. IntOp $R0 $R0 | ${SF_SELECTED}
  368. SectionSetFlags ${SecPython} $R0
  369. Abort
  370. SkipCheck:
  371. FunctionEnd
  372. Section "C++ support" SecHeadersLibs
  373. SectionIn 1
  374. SetDetailsPrint both
  375. DetailPrint "Installing header files..."
  376. SetDetailsPrint listonly
  377. SetOutPath $INSTDIR\include
  378. File /r /x *.exp "${BUILT}\include\*"
  379. SetDetailsPrint both
  380. DetailPrint "Installing library archives..."
  381. SetDetailsPrint listonly
  382. SetOutPath $INSTDIR\lib
  383. File /r /x *.exp "${BUILT}\lib\*"
  384. SectionEnd
  385. !ifdef HAVE_SAMPLES
  386. Section "Sample programs" SecSamples
  387. SectionIn 1
  388. ; Necessary for proper start menu shortcut installation
  389. SetShellVarContext current
  390. SetDetailsPrint both
  391. DetailPrint "Installing sample programs..."
  392. SetDetailsPrint listonly
  393. SetOutPath $INSTDIR\samples
  394. File /nonfatal /r /x CVS "${SOURCE}\samples\*"
  395. SetDetailsPrint both
  396. DetailPrint "Creating shortcuts..."
  397. SetDetailsPrint listonly
  398. SetOutPath $INSTDIR
  399. WriteINIStr $INSTDIR\Website.url "InternetShortcut" "URL" "https://www.panda3d.org/"
  400. WriteINIStr $INSTDIR\Manual.url "InternetShortcut" "URL" "https://www.panda3d.org/manual/index.php"
  401. WriteINIStr $INSTDIR\Samples.url "InternetShortcut" "URL" "https://www.panda3d.org/manual/index.php/Sample_Programs_in_the_Distribution"
  402. SetOutPath $INSTDIR
  403. CreateShortCut "$SMPROGRAMS\${TITLE}\Panda3D Manual.lnk" "$INSTDIR\Manual.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Panda3D Manual"
  404. CreateShortCut "$SMPROGRAMS\${TITLE}\Panda3D Website.lnk" "$INSTDIR\Website.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Panda3D Website"
  405. CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Program Manual.lnk" "$INSTDIR\Samples.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Sample Program Manual"
  406. FindFirst $0 $1 $INSTDIR\samples\*
  407. loop:
  408. StrCmp $1 "" done
  409. StrCmp $1 "." next
  410. StrCmp $1 ".." next
  411. Push $1
  412. Push "-"
  413. Push " "
  414. Call StrRep
  415. Call Capitalize
  416. Pop $R0
  417. StrCpy $READABLE $R0
  418. Push $1
  419. Push "-"
  420. Push "_"
  421. Call StrRep
  422. Pop $R0
  423. StrCpy $MANPAGE $R0
  424. DetailPrint "Creating shortcuts for sample program $READABLE"
  425. CreateDirectory "$SMPROGRAMS\${TITLE}\Sample Programs\$READABLE"
  426. SetOutPath $INSTDIR\samples\$1
  427. WriteINIStr $INSTDIR\samples\$1\ManualPage.url "InternetShortcut" "URL" "http://panda3d.org/wiki/index.php/Sample_Programs:_$MANPAGE"
  428. CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Programs\$READABLE\Manual Page.lnk" "$INSTDIR\samples\$1\ManualPage.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Manual Entry on this Sample Program"
  429. CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Programs\$READABLE\View Source Code.lnk" "$INSTDIR\samples\$1"
  430. FindFirst $2 $3 $INSTDIR\samples\$1\*.py
  431. iloop:
  432. StrCmp $3 "" idone
  433. CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Programs\$READABLE\Run $3.lnk" "$INSTDIR\python\python.exe" "-E $3" "$INSTDIR\bin\eggcacher.exe" 0 SW_SHOWMINIMIZED "" "Run $3"
  434. CreateShortCut "$INSTDIR\samples\$1\Run $3.lnk" "$INSTDIR\python\python.exe" "-E $3" "$INSTDIR\bin\eggcacher.exe" 0 SW_SHOWMINIMIZED "" "Run $3"
  435. FindNext $2 $3
  436. goto iloop
  437. idone:
  438. next:
  439. FindNext $0 $1
  440. Goto loop
  441. done:
  442. SectionEnd
  443. !endif
  444. !ifdef HAVE_MAX_PLUGINS
  445. Section "3ds Max plug-ins" SecMaxPlugins
  446. SectionIn 1 3
  447. SetDetailsPrint both
  448. DetailPrint "Installing Autodesk 3ds Max plug-ins..."
  449. SetDetailsPrint listonly
  450. SetOutPath $INSTDIR\plugins
  451. File /nonfatal /r "${BUILT}\plugins\*.dle"
  452. File /nonfatal /r "${BUILT}\plugins\*.dlo"
  453. File "${SOURCE}\doc\INSTALLING-PLUGINS.TXT"
  454. SectionEnd
  455. !endif
  456. !ifdef HAVE_MAYA_PLUGINS
  457. Section "Maya plug-ins" SecMayaPlugins
  458. SectionIn 1 3
  459. SetDetailsPrint both
  460. DetailPrint "Installing Autodesk Maya plug-ins..."
  461. SetDetailsPrint listonly
  462. SetOutPath $INSTDIR\plugins
  463. File /nonfatal /r "${BUILT}\plugins\*.mll"
  464. File /nonfatal /r "${BUILT}\plugins\*.mel"
  465. File /nonfatal /r "${BUILT}\plugins\*.ms"
  466. File "${SOURCE}\doc\INSTALLING-PLUGINS.TXT"
  467. SectionEnd
  468. !endif
  469. Section -post
  470. !ifdef REGVIEW
  471. SetRegView ${REGVIEW}
  472. !endif
  473. ; Run eggcacher. We can't do this in SecCore because we haven't
  474. ; installed eggcacher at that point yet.
  475. SetDetailsPrint both
  476. DetailPrint "Preloading .egg files into the model cache..."
  477. SetDetailsPrint listonly
  478. ; We need to set the $PATH for eggcacher.
  479. SetOutPath $INSTDIR
  480. ReadEnvStr $R0 "PATH"
  481. StrCpy $R0 "$INSTDIR\python;$INSTDIR\bin;$R0"
  482. System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PATH", R0).r2'
  483. nsExec::ExecToLog '"$INSTDIR\bin\eggcacher.exe" --concise models samples'
  484. SetDetailsPrint both
  485. DetailPrint "Writing the uninstaller ..."
  486. SetDetailsPrint listonly
  487. Delete "$INSTDIR\uninst.exe"
  488. WriteUninstaller "$INSTDIR\uninst.exe"
  489. WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${TITLE}" "DisplayName" "${TITLE}"
  490. WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${TITLE}" "UninstallString" '"$INSTDIR\uninst.exe"'
  491. SetOutPath $INSTDIR
  492. CreateShortcut "$SMPROGRAMS\${TITLE}\Uninstall ${TITLE}.lnk" "$INSTDIR\uninst.exe" ""
  493. SetDetailsPrint both
  494. DetailPrint "Adding directories to system PATH..."
  495. SetDetailsPrint listonly
  496. # Add the "bin" directory to the PATH.
  497. Push "$INSTDIR\python"
  498. Call RemoveFromPath
  499. Push "$INSTDIR\python\Scripts"
  500. Call RemoveFromPath
  501. Push "$INSTDIR\bin"
  502. Call RemoveFromPath
  503. Push "$INSTDIR\python"
  504. Call AddToPath
  505. Push "$INSTDIR\python\Scripts"
  506. Call AddToPath
  507. Push "$INSTDIR\bin"
  508. Call AddToPath
  509. # This is needed for the environment variable changes to take effect.
  510. DetailPrint "Broadcasting WM_WININICHANGE message..."
  511. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=500
  512. SectionEnd
  513. Section Uninstall
  514. SetDetailsPrint listonly
  515. SetShellVarContext current
  516. !ifdef REGVIEW
  517. SetRegView ${REGVIEW}
  518. !endif
  519. SetDetailsPrint both
  520. DetailPrint "Removing registry entries..."
  521. SetDetailsPrint listonly
  522. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${TITLE}"
  523. DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${TITLE}"
  524. ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" ""
  525. StrCmp $0 "$INSTDIR\python" 0 SkipUnRegHKLM
  526. DeleteRegKey HKLM "Software\Python\PythonCore\${PYVER}"
  527. SkipUnRegHKLM:
  528. ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" ""
  529. StrCmp $0 "$INSTDIR\python" 0 SkipUnRegHKCU
  530. DeleteRegKey HKCU "Software\Python\PythonCore\${PYVER}"
  531. SkipUnRegHKCU:
  532. SetDetailsPrint both
  533. DetailPrint "Deleting files..."
  534. SetDetailsPrint listonly
  535. Delete "$INSTDIR\uninst.exe"
  536. RMDir /r "$INSTDIR"
  537. SetDetailsPrint both
  538. DetailPrint "Removing Start Menu entries..."
  539. SetDetailsPrint listonly
  540. SetShellVarContext current
  541. RMDir /r "$SMPROGRAMS\${TITLE}"
  542. SetShellVarContext all
  543. RMDir /r "$SMPROGRAMS\${TITLE}"
  544. SetDetailsPrint both
  545. DetailPrint "Removing entries from PATH..."
  546. SetDetailsPrint listonly
  547. Push "$INSTDIR\python"
  548. Call un.RemoveFromPath
  549. Push "$INSTDIR\python\Scripts"
  550. Call un.RemoveFromPath
  551. Push "$INSTDIR\bin"
  552. Call un.RemoveFromPath
  553. # This is needed for the environment variable changes to take effect.
  554. DetailPrint "Broadcasting WM_WININICHANGE message..."
  555. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=500
  556. SectionEnd
  557. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  558. !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} $(DESC_SecCore)
  559. !ifdef HAVE_GL
  560. !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenGL} $(DESC_SecOpenGL)
  561. !endif
  562. !ifdef HAVE_DX9
  563. !insertmacro MUI_DESCRIPTION_TEXT ${SecDirect3D9} $(DESC_SecDirect3D9)
  564. !endif
  565. !ifdef HAVE_OPENAL
  566. !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenAL} $(DESC_SecOpenAL)
  567. !endif
  568. !ifdef HAVE_FMOD
  569. !insertmacro MUI_DESCRIPTION_TEXT ${SecFMOD} $(DESC_SecFMOD)
  570. !endif
  571. !ifdef HAVE_FFMPEG
  572. !insertmacro MUI_DESCRIPTION_TEXT ${SecFFMpeg} $(DESC_SecFFMpeg)
  573. !endif
  574. !ifdef HAVE_BULLET
  575. !insertmacro MUI_DESCRIPTION_TEXT ${SecBullet} $(DESC_SecBullet)
  576. !endif
  577. !ifdef HAVE_ODE
  578. !insertmacro MUI_DESCRIPTION_TEXT ${SecODE} $(DESC_SecODE)
  579. !endif
  580. !ifdef HAVE_PHYSX
  581. !insertmacro MUI_DESCRIPTION_TEXT ${SecPhysX} $(DESC_SecPhysX)
  582. !endif
  583. !ifdef HAVE_ROCKET
  584. !insertmacro MUI_DESCRIPTION_TEXT ${SecRocket} $(DESC_SecRocket)
  585. !endif
  586. !insertmacro MUI_DESCRIPTION_TEXT ${SecTools} $(DESC_SecTools)
  587. !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings} $(DESC_SecPyBindings)
  588. !insertmacro MUI_DESCRIPTION_TEXT ${SecPython} $(DESC_SecPython)
  589. !insertmacro MUI_DESCRIPTION_TEXT ${SecHeadersLibs} $(DESC_SecHeadersLibs)
  590. !insertmacro MUI_DESCRIPTION_TEXT ${SecSamples} $(DESC_SecSamples)
  591. !ifdef HAVE_MAX_PLUGINS
  592. !insertmacro MUI_DESCRIPTION_TEXT ${SecMaxPlugins} $(DESC_SecMaxPlugins)
  593. !endif
  594. !ifdef HAVE_MAYA_PLUGINS
  595. !insertmacro MUI_DESCRIPTION_TEXT ${SecMayaPlugins} $(DESC_SecMayaPlugins)
  596. !endif
  597. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  598. # --[ Utility Functions ]------------------------------------------------------
  599. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  600. Function IsNT
  601. Push $0
  602. ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  603. StrCmp $0 "" 0 IsNT_yes
  604. ; we are not NT.
  605. Pop $0
  606. Push 0
  607. Return
  608. IsNT_yes:
  609. ; NT!!!
  610. Pop $0
  611. Push 1
  612. FunctionEnd
  613. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  614. Function un.IsNT
  615. Push $0
  616. ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  617. StrCmp $0 "" 0 unIsNT_yes
  618. ; we are not NT.
  619. Pop $0
  620. Push 0
  621. Return
  622. unIsNT_yes:
  623. ; NT!!!
  624. Pop $0
  625. Push 1
  626. FunctionEnd
  627. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  628. Function StrStr
  629. Push $0
  630. Exch
  631. Pop $0 ; $0 now have the string to find
  632. Push $1
  633. Exch 2
  634. Pop $1 ; $1 now have the string to find in
  635. Exch
  636. Push $2
  637. Push $3
  638. Push $4
  639. Push $5
  640. StrCpy $2 -1
  641. StrLen $3 $0
  642. StrLen $4 $1
  643. IntOp $4 $4 - $3
  644. unStrStr_loop:
  645. IntOp $2 $2 + 1
  646. IntCmp $2 $4 0 0 unStrStrReturn_notFound
  647. StrCpy $5 $1 $3 $2
  648. StrCmp $5 $0 unStrStr_done unStrStr_loop
  649. unStrStrReturn_notFound:
  650. StrCpy $2 -1
  651. unStrStr_done:
  652. Pop $5
  653. Pop $4
  654. Pop $3
  655. Exch $2
  656. Exch 2
  657. Pop $0
  658. Pop $1
  659. FunctionEnd
  660. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  661. Function un.StrStr
  662. Push $0
  663. Exch
  664. Pop $0 ; $0 now have the string to find
  665. Push $1
  666. Exch 2
  667. Pop $1 ; $1 now have the string to find in
  668. Exch
  669. Push $2
  670. Push $3
  671. Push $4
  672. Push $5
  673. StrCpy $2 -1
  674. StrLen $3 $0
  675. StrLen $4 $1
  676. IntOp $4 $4 - $3
  677. unStrStr_loop:
  678. IntOp $2 $2 + 1
  679. IntCmp $2 $4 0 0 unStrStrReturn_notFound
  680. StrCpy $5 $1 $3 $2
  681. StrCmp $5 $0 unStrStr_done unStrStr_loop
  682. unStrStrReturn_notFound:
  683. StrCpy $2 -1
  684. unStrStr_done:
  685. Pop $5
  686. Pop $4
  687. Pop $3
  688. Exch $2
  689. Exch 2
  690. Pop $0
  691. Pop $1
  692. FunctionEnd
  693. ; Capitalizes the first letter of every word.
  694. Function Capitalize
  695. Exch $R0
  696. Push $0
  697. Push $1
  698. Push $2
  699. StrCpy $0 0
  700. capNext:
  701. ; Grab the next character.
  702. StrCpy $1 $R0 1 $0
  703. StrCmp $1 '' end
  704. ; Capitalize it.
  705. ${StrFilter} '$1' '+eng' '' '' $1
  706. ${StrFilter} '$1' '+rus' '' '' $1
  707. ; Splice it into the string.
  708. StrCpy $2 $R0 $0
  709. IntOp $0 $0 + 1
  710. StrCpy $R0 $R0 '' $0
  711. StrCpy $R0 '$2$1$R0'
  712. ; Keep looping through the characters until we find a
  713. ; delimiter or reach the end of the string.
  714. loop:
  715. StrCpy $1 $R0 1 $0
  716. IntOp $0 $0 + 1
  717. StrCmp $1 '' end
  718. StrCmp $1 ' ' capNext
  719. StrCmp $1 '_' capNext
  720. StrCmp $1 '-' capNext
  721. StrCmp $1 '(' capNext
  722. StrCmp $1 '[' capNext
  723. Goto loop
  724. end:
  725. Pop $2
  726. Pop $1
  727. Pop $0
  728. Exch $R0
  729. FunctionEnd
  730. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  731. ; Commentary and smarter ';' checking by Jon Parise <[email protected]>
  732. Function AddToPath
  733. Exch $0
  734. Push $1
  735. Push $2
  736. Push $3
  737. Call IsNT
  738. Pop $1
  739. DetailPrint "Adding to PATH: $0"
  740. StrCmp $1 1 AddToPath_NT
  741. ; We're not on NT, so modify the AUTOEXEC.BAT file.
  742. StrCpy $1 $WINDIR 2
  743. FileOpen $1 "$1\autoexec.bat" a
  744. FileSeek $1 0 END
  745. GetFullPathName /SHORT $0 $0
  746. FileWrite $1 "$\r$\nSET PATH=%PATH%;$0$\r$\n"
  747. FileClose $1
  748. Goto AddToPath_done
  749. AddToPath_NT:
  750. ReadRegStr $1 HKCU "Environment" "PATH"
  751. Call IsUserAdmin
  752. Pop $3
  753. ; If this is an Admin user, use the System env. variable instead of the user's env. variable
  754. StrCmp $3 1 0 +2
  755. ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
  756. ; If the PATH string is empty, jump over the mangling routines.
  757. StrCmp $1 "" AddToPath_NTdoIt
  758. ; Pull off the last character of the PATH string. If it's a semicolon,
  759. ; we don't need to add another one, so jump to the section where we
  760. ; append the new PATH component(s).
  761. StrCpy $2 $1 1 -1
  762. StrCmp $2 ";" AddToPath_NTAddPath AddToPath_NTAddSemi
  763. AddToPath_NTAddSemi:
  764. StrCpy $1 "$1;"
  765. Goto AddToPath_NTAddPath
  766. AddToPath_NTAddPath:
  767. StrCpy $0 "$1$0"
  768. Goto AddToPath_NTdoIt
  769. AddToPath_NTdoIt:
  770. Call IsUserAdmin
  771. Pop $3
  772. StrCmp $3 1 0 NotAdmin
  773. WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $0
  774. Goto AddToPath_done
  775. NotAdmin:
  776. WriteRegExpandStr HKCU "Environment" "PATH" $0
  777. AddToPath_done:
  778. Pop $3
  779. Pop $2
  780. Pop $1
  781. Pop $0
  782. FunctionEnd
  783. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  784. Function RemoveFromPath
  785. Exch $0
  786. Push $1
  787. Push $2
  788. Push $3
  789. Push $4
  790. Push $5
  791. Call IsNT
  792. Pop $1
  793. DetailPrint "Removing from PATH: $0"
  794. StrCmp $1 1 unRemoveFromPath_NT
  795. ; Not on NT
  796. StrCpy $1 $WINDIR 2
  797. FileOpen $1 "$1\autoexec.bat" r
  798. GetTempFileName $4
  799. FileOpen $2 $4 w
  800. GetFullPathName /SHORT $0 $0
  801. StrCpy $0 "SET PATH=%PATH%;$0"
  802. SetRebootFlag true
  803. Goto unRemoveFromPath_dosLoop
  804. unRemoveFromPath_dosLoop:
  805. FileRead $1 $3
  806. StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoop
  807. StrCmp $3 "$0$\n" unRemoveFromPath_dosLoop
  808. StrCmp $3 "$0" unRemoveFromPath_dosLoop
  809. StrCmp $3 "" unRemoveFromPath_dosLoopEnd
  810. FileWrite $2 $3
  811. Goto unRemoveFromPath_dosLoop
  812. unRemoveFromPath_dosLoopEnd:
  813. FileClose $2
  814. FileClose $1
  815. StrCpy $1 $WINDIR 2
  816. Delete "$1\autoexec.bat"
  817. CopyFiles /SILENT $4 "$1\autoexec.bat"
  818. Delete $4
  819. Goto unRemoveFromPath_done
  820. unRemoveFromPath_NT:
  821. StrLen $2 $0
  822. Call IsUserAdmin
  823. Pop $5
  824. StrCmp $5 1 0 NotAdmin
  825. ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
  826. Push $1
  827. Push $0
  828. Call StrStr ; Find $0 in $1
  829. Pop $0 ; pos of our dir
  830. IntCmp $0 -1 unRemoveFromPath_done
  831. ; else, it is in path
  832. StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
  833. IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
  834. IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
  835. StrLen $0 $1
  836. StrCpy $1 $1 $0 $2
  837. StrCpy $3 "$3$1"
  838. WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $3
  839. Goto unRemoveFromPath_done
  840. NotAdmin:
  841. ReadRegStr $1 HKCU "Environment" "PATH"
  842. Push $1
  843. Push $0
  844. Call StrStr ; Find $0 in $1
  845. Pop $0 ; pos of our dir
  846. IntCmp $0 -1 unRemoveFromPath_done
  847. ; else, it is in path
  848. StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
  849. IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
  850. IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
  851. StrLen $0 $1
  852. StrCpy $1 $1 $0 $2
  853. StrCpy $3 "$3$1"
  854. WriteRegExpandStr HKCU "Environment" "PATH" $3
  855. unRemoveFromPath_done:
  856. Pop $5
  857. Pop $4
  858. Pop $3
  859. Pop $2
  860. Pop $1
  861. Pop $0
  862. FunctionEnd
  863. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  864. Function un.RemoveFromPath
  865. Exch $0
  866. Push $1
  867. Push $2
  868. Push $3
  869. Push $4
  870. Push $5
  871. Call un.IsNT
  872. Pop $1
  873. StrCmp $1 1 unRemoveFromPath_NT
  874. ; Not on NT
  875. StrCpy $1 $WINDIR 2
  876. FileOpen $1 "$1\autoexec.bat" r
  877. GetTempFileName $4
  878. FileOpen $2 $4 w
  879. GetFullPathName /SHORT $0 $0
  880. StrCpy $0 "SET PATH=%PATH%;$0"
  881. SetRebootFlag true
  882. Goto unRemoveFromPath_dosLoop
  883. unRemoveFromPath_dosLoop:
  884. FileRead $1 $3
  885. StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoop
  886. StrCmp $3 "$0$\n" unRemoveFromPath_dosLoop
  887. StrCmp $3 "$0" unRemoveFromPath_dosLoop
  888. StrCmp $3 "" unRemoveFromPath_dosLoopEnd
  889. FileWrite $2 $3
  890. Goto unRemoveFromPath_dosLoop
  891. unRemoveFromPath_dosLoopEnd:
  892. FileClose $2
  893. FileClose $1
  894. StrCpy $1 $WINDIR 2
  895. Delete "$1\autoexec.bat"
  896. CopyFiles /SILENT $4 "$1\autoexec.bat"
  897. Delete $4
  898. Goto unRemoveFromPath_done
  899. unRemoveFromPath_NT:
  900. StrLen $2 $0
  901. Call un.IsUserAdmin
  902. Pop $5
  903. StrCmp $5 1 0 NotAdmin
  904. ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
  905. Push $1
  906. Push $0
  907. Call un.StrStr ; Find $0 in $1
  908. Pop $0 ; pos of our dir
  909. IntCmp $0 -1 unRemoveFromPath_done
  910. ; else, it is in path
  911. StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
  912. IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
  913. IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
  914. StrLen $0 $1
  915. StrCpy $1 $1 $0 $2
  916. StrCpy $3 "$3$1"
  917. WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $3
  918. Goto unRemoveFromPath_done
  919. NotAdmin:
  920. ReadRegStr $1 HKCU "Environment" "PATH"
  921. Push $1
  922. Push $0
  923. Call un.StrStr ; Find $0 in $1
  924. Pop $0 ; pos of our dir
  925. IntCmp $0 -1 unRemoveFromPath_done
  926. ; else, it is in path
  927. StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
  928. IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
  929. IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
  930. StrLen $0 $1
  931. StrCpy $1 $1 $0 $2
  932. StrCpy $3 "$3$1"
  933. WriteRegExpandStr HKCU "Environment" "PATH" $3
  934. unRemoveFromPath_done:
  935. Pop $5
  936. Pop $4
  937. Pop $3
  938. Pop $2
  939. Pop $1
  940. Pop $0
  941. FunctionEnd
  942. ; From: http://nsis.sourceforge.net/archive/nsisweb.php?page=329&instances=0,11
  943. ; Localized by Ben Johnson ([email protected])
  944. Function IsUserAdmin
  945. Push $0
  946. Push $1
  947. Push $2
  948. Push $3
  949. Call IsNT
  950. Pop $1
  951. ClearErrors
  952. UserInfo::GetName
  953. ;IfErrors Win9x
  954. Pop $2
  955. UserInfo::GetAccountType
  956. Pop $3
  957. ; Compare results of IsNT with "1"
  958. StrCmp $1 1 0 NotNT
  959. ;This is NT
  960. StrCmp $3 "Admin" 0 NotAdmin
  961. ; Observation: I get here when running Win98SE. (Lilla)
  962. ; The functions UserInfo.dll looks for are there on Win98 too,
  963. ; but just don't work. So UserInfo.dll, knowing that admin isn't required
  964. ; on Win98, returns admin anyway. (per kichik)
  965. ; MessageBox MB_OK 'User "$R1" is in the Administrators group'
  966. Pop $3
  967. Pop $2
  968. Pop $1
  969. Pop $0
  970. Push 1
  971. Return
  972. NotAdmin:
  973. ; You should still check for an empty string because the functions
  974. ; UserInfo.dll looks for may not be present on Windows 95. (per kichik)
  975. #StrCmp $2 "" Win9x
  976. #StrCpy $0 0
  977. ;MessageBox MB_OK 'User "$2" is in the "$3" group'
  978. Pop $3
  979. Pop $2
  980. Pop $1
  981. Pop $0
  982. Push 0
  983. Return
  984. ;Because we use IsNT, this is redundant.
  985. #Win9x:
  986. # ; comment/message below is by UserInfo.nsi author:
  987. # ; This one means you don't need to care about admin or
  988. # ; not admin because Windows 9x doesn't either
  989. # ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!"
  990. # StrCpy $0 0
  991. NotNT:
  992. ;We are not NT
  993. ;Win9x doesn't have "admin" users.
  994. ;Let the user do whatever.
  995. Pop $3
  996. Pop $2
  997. Pop $1
  998. Pop $0
  999. Push 1
  1000. FunctionEnd
  1001. Function un.IsUserAdmin
  1002. Push $0
  1003. Push $1
  1004. Push $2
  1005. Push $3
  1006. Call un.IsNT
  1007. Pop $1
  1008. ClearErrors
  1009. UserInfo::GetName
  1010. ;IfErrors Win9x
  1011. Pop $2
  1012. UserInfo::GetAccountType
  1013. Pop $3
  1014. ; Compare results of IsNT with "1"
  1015. StrCmp $1 1 0 NotNT
  1016. ;This is NT
  1017. StrCmp $3 "Admin" 0 NotAdmin
  1018. ; Observation: I get here when running Win98SE. (Lilla)
  1019. ; The functions UserInfo.dll looks for are there on Win98 too,
  1020. ; but just don't work. So UserInfo.dll, knowing that admin isn't required
  1021. ; on Win98, returns admin anyway. (per kichik)
  1022. ; MessageBox MB_OK 'User "$R1" is in the Administrators group'
  1023. Pop $3
  1024. Pop $2
  1025. Pop $1
  1026. Pop $0
  1027. Push 1
  1028. Return
  1029. NotAdmin:
  1030. ; You should still check for an empty string because the functions
  1031. ; UserInfo.dll looks for may not be present on Windows 95. (per kichik)
  1032. #StrCmp $2 "" Win9x
  1033. #StrCpy $0 0
  1034. ;MessageBox MB_OK 'User "$2" is in the "$3" group'
  1035. Pop $3
  1036. Pop $2
  1037. Pop $1
  1038. Pop $0
  1039. Push 0
  1040. Return
  1041. ;Because we use IsNT, this is redundant.
  1042. #Win9x:
  1043. # ; comment/message below is by UserInfo.nsi author:
  1044. # ; This one means you don't need to care about admin or
  1045. # ; not admin because Windows 9x doesn't either
  1046. # ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!"
  1047. # StrCpy $0 0
  1048. NotNT:
  1049. ;We are not NT
  1050. ;Win9x doesn't have "admin" users.
  1051. ;Let the user do whatever.
  1052. Pop $3
  1053. Pop $2
  1054. Pop $1
  1055. Pop $0
  1056. Push 1
  1057. FunctionEnd
  1058. Function StrRep
  1059. ;Written by dirtydingus 2003-02-20 04:30:09
  1060. ; USAGE
  1061. ;Push String to do replacement in (haystack)
  1062. ;Push String to replace (needle)
  1063. ;Push Replacement
  1064. ;Call StrRep
  1065. ;Pop $R0 result
  1066. ;StrCpy $Result STR $R0
  1067. Exch $R4 ; $R4 = Replacement String
  1068. Exch
  1069. Exch $R3 ; $R3 = String to replace (needle)
  1070. Exch 2
  1071. Exch $R1 ; $R1 = String to do replacement in (haystack)
  1072. Push $R2 ; Replaced haystack
  1073. Push $R5 ; Len (needle)
  1074. Push $R6 ; len (haystack)
  1075. Push $R7 ; Scratch reg
  1076. StrCpy $R2 ""
  1077. StrLen $R5 $R3
  1078. StrLen $R6 $R1
  1079. loop:
  1080. StrCpy $R7 $R1 $R5
  1081. StrCmp $R7 $R3 found
  1082. StrCpy $R7 $R1 1 ; - optimization can be removed if U know len needle=1
  1083. StrCpy $R2 "$R2$R7"
  1084. StrCpy $R1 $R1 $R6 1
  1085. StrCmp $R1 "" done loop
  1086. found:
  1087. StrCpy $R2 "$R2$R4"
  1088. StrCpy $R1 $R1 $R6 $R5
  1089. StrCmp $R1 "" done loop
  1090. done:
  1091. StrCpy $R3 $R2
  1092. Pop $R7
  1093. Pop $R6
  1094. Pop $R5
  1095. Pop $R2
  1096. Pop $R1
  1097. Pop $R4
  1098. Exch $R3
  1099. FunctionEnd