; Script generated by the HM NIS Edit Script Wizard. ; HM NIS Edit Wizard helper defines !define PRODUCT_VERSION "0.1.0a1" !define PRODUCT_NAME "NanoVision-1 ${PRODUCT_VERSION}" !define PRODUCT_PUBLISHER "Nanorex, Inc" !define PRODUCT_WEB_SITE "http://www.nanorex.com" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\nv1.exe" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" !macro ReplaceInFile SOURCE_FILE SEARCH_TEXT REPLACEMENT Push "${SOURCE_FILE}" Push "${SEARCH_TEXT}" Push "${REPLACEMENT}" Call RIF !macroend ; MUI 1.67 compatible ------ !include "MUI.nsh" ; MUI Settings !define MUI_ABORTWARNING !define MUI_ICON "install.ico" !define MUI_UNICON "uninstall.ico" ; Welcome page !insertmacro MUI_PAGE_WELCOME ; License page !insertmacro MUI_PAGE_LICENSE "License.txt" ; Components page !insertmacro MUI_PAGE_COMPONENTS ; Directory page !insertmacro MUI_PAGE_DIRECTORY ; Instfiles page !insertmacro MUI_PAGE_INSTFILES ; Finish page !define MUI_FINISHPAGE_RUN "$INSTDIR\bin\nv1.exe" !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\ReadMe.html" !insertmacro MUI_PAGE_FINISH ; Uninstaller pages !insertmacro MUI_UNPAGE_INSTFILES ; Language files !insertmacro MUI_LANGUAGE "English" ; MUI end ------ Name "${PRODUCT_NAME}" OutFile "NanoVision-1-${PRODUCT_VERSION}-setup.exe" InstallDir "$PROGRAMFILES\Nanorex\NanoVision-1" InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" ShowInstDetails show ShowUnInstDetails show SectionGroup /e "NanoVision-1" Section "NanoVision-1 Base" NV1_BASE SetOutPath "$INSTDIR\bin" SetOverwrite try File "bin\*" CreateDirectory "$SMPROGRAMS\Nanorex\NanoVision-1" CreateShortCut "$SMPROGRAMS\Nanorex\NanoVision-1\NanoVision-1.lnk" "$INSTDIR\bin\nv1.exe" CreateShortCut "$DESKTOP\NanoVision-1.lnk" "$INSTDIR\bin\nv1.exe" SetOutPath "$INSTDIR\include" File /r "include\*" SetOutPath "$INSTDIR\lib" File /r "lib\*" SetOutPath "$INSTDIR" SetOverwrite on File "ReadMe.html" File "License.txt" SetOutPath "$APPDATA\Nanorex" File "NanoVision-1.ini" Push "$INSTDIR\lib" Push "\" Push "/" Call StrRep Pop "$R0" ;result !insertmacro ReplaceInFile "$APPDATA\Nanorex\NanoVision-1.ini" "@PLUGSRCHPATH@" "$R0" SetOutPath "$INSTDIR" SectionEnd Section /o "source" NV1_SRC SetOutPath "$INSTDIR\source" File /r "src\*" SectionEnd SectionGroupEnd Section -AdditionalIcons WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" CreateShortCut "$SMPROGRAMS\Nanorex\NanoVision-1\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url" CreateShortCut "$SMPROGRAMS\Nanorex\NanoVision-1\Uninstall.lnk" "$INSTDIR\uninst.exe" SectionEnd Section -Post WriteUninstaller "$INSTDIR\uninst.exe" WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\bin\nv1.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bin\nv1.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" SectionEnd ; Section descriptions !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${NV1_BASE} "NanoVision-1 main program." !insertmacro MUI_DESCRIPTION_TEXT ${NV1_SRC} "Source code" !insertmacro MUI_FUNCTION_DESCRIPTION_END Function un.onUninstSuccess HideWindow MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." FunctionEnd Function un.onInit MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2 Abort FunctionEnd Section Uninstall Delete "$SMPROGRAMS\Nanorex\NanoVision-1\Uninstall.lnk" Delete "$SMPROGRAMS\Nanorex\NanoVision-1\Website.lnk" Delete "$DESKTOP\NanoVision-1.lnk" Delete "$SMPROGRAMS\Nanorex\NanoVision-1\NanoVision-1.lnk" Delete "$APPDATA\Nanorex\NanoVision-1.ini" Delete "$INSTDIR\*" RMDir "$SMPROGRAMS\Nanorex\NanoVision-1" RMDir "$SMPROGRAMS\Nanorex" RMDir /r "$INSTDIR\bin" RMDir /r "$INSTDIR\lib" RMDir /r "$INSTDIR\include" RMDir /r "$INSTDIR\source" RMDir "$APPDATA\Nanorex" RMDir "$INSTDIR" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}" SetAutoClose true SectionEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Function RIF ClearErrors ; wanna be a newborn Exch $0 ; REPLACEMENT Exch Exch $1 ; SEARCH_TEXT Exch 2 Exch $2 ; SOURCE_FILE Push $R0 ; SOURCE_FILE file handle Push $R1 ; temporary file handle Push $R2 ; unique temporary file name Push $R3 ; a line to sar/save Push $R4 ; shift puffer IfFileExists $2 +1 RIF_error ; knock-knock FileOpen $R0 $2 "r" ; open the door GetTempFileName $R2 ; who's new? FileOpen $R1 $R2 "w" ; the escape, please! RIF_loop: ; round'n'round we go FileRead $R0 $R3 ; read one line IfErrors RIF_leaveloop ; enough is enough RIF_sar: ; sar - search and replace Push "$R3" ; (hair)stack Push "$1" ; needle Push "$0" ; blood Call StrReplace ; do the bartwalk StrCpy $R4 "$R3" ; remember previous state Pop $R3 ; gimme s.th. back in return! StrCmp "$R3" "$R4" +1 RIF_sar ; loop, might change again! FileWrite $R1 "$R3" ; save the newbie Goto RIF_loop ; gimme more RIF_leaveloop: ; over'n'out, Sir! FileClose $R1 ; S'rry, Ma'am - clos'n now FileClose $R0 ; me 2 Delete "$2.old" ; go away, Sire Rename "$2" "$2.old" ; step aside, Ma'am Rename "$R2" "$2" ; hi, baby! Delete "$2.old" ; Nano-Hive addition ClearErrors ; now i AM a newborn Goto RIF_out ; out'n'away RIF_error: ; ups - s.th. went wrong... SetErrors ; ...so cry, boy! RIF_out: ; your wardrobe? Pop $R4 Pop $R3 Pop $R2 Pop $R1 Pop $R0 Pop $2 Pop $0 Pop $1 FunctionEnd Function StrReplace Exch $0 ;this will replace wrong characters Exch Exch $1 ;needs to be replaced Exch Exch 2 Exch $2 ;the orginal string Push $3 ;counter Push $4 ;temp character Push $5 ;temp string Push $6 ;length of string that need to be replaced Push $7 ;length of string that will replace Push $R0 ;tempstring Push $R1 ;tempstring Push $R2 ;tempstring StrCpy $3 "-1" StrCpy $5 "" StrLen $6 $1 StrLen $7 $0 Loop: IntOp $3 $3 + 1 StrCpy $4 $2 $6 $3 StrCmp $4 "" ExitLoop StrCmp $4 $1 Replace Goto Loop Replace: StrCpy $R0 $2 $3 IntOp $R2 $3 + $6 StrCpy $R1 $2 "" $R2 StrCpy $2 $R0$0$R1 IntOp $3 $3 + $7 Goto Loop ExitLoop: StrCpy $0 $2 Pop $R2 Pop $R1 Pop $R0 Pop $7 Pop $6 Pop $5 Pop $4 Pop $3 Pop $2 Pop $1 Exch $0 FunctionEnd Function StrRep Exch $R4 ; $R4 = Replacement String Exch Exch $R3 ; $R3 = String to replace (needle) Exch 2 Exch $R1 ; $R1 = String to do replacement in (haystack) Push $R2 ; Replaced haystack Push $R5 ; Len (needle) Push $R6 ; len (haystack) Push $R7 ; Scratch reg StrCpy $R2 "" StrLen $R5 $R3 StrLen $R6 $R1 loop: StrCpy $R7 $R1 $R5 StrCmp $R7 $R3 found StrCpy $R7 $R1 1 ; - optimization can be removed if U know len needle=1 StrCpy $R2 "$R2$R7" StrCpy $R1 $R1 $R6 1 StrCmp $R1 "" done loop found: StrCpy $R2 "$R2$R4" StrCpy $R1 $R1 $R6 $R5 StrCmp $R1 "" done loop done: StrCpy $R3 $R2 Pop $R7 Pop $R6 Pop $R5 Pop $R2 Pop $R1 Pop $R4 Exch $R3 FunctionEnd