installer.nsi 45 KB

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