# Auto-generated by EclipseNSIS Script Wizard # Oct 29, 2006 5:23:20 PM Name "Turey's Java Utilities" # Defines !define REGKEY "SOFTWARE\$(^Name)" !define COMPANY "Turey" # MUI defines !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" !define MUI_DIRECTORYPAGE_TEXT_TOP "Locate Your JDK/JRE Directory.$\nThis is needed so that this installer can update your PATH Environment Variable to allow universal execution of the required files.$\n$\nI know it says all over this page that you are choosing where to install the Java Utilities, but you're really just selecting the place you installed the JDK.$\nSorry for the confusion." !define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Example: C:\Program Files\Java\jdk1.5.0_09" !define MUI_DIRECTORYPAGE_VARIABLE $9 !define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_FINISHPAGE_SHOWREADME "$PROGRAMFILES\Java Utilities\javautilities.txt" !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" !define MUI_UNFINISHPAGE_NOAUTOCLOSE # Included files !include Sections.nsh !include MUI.nsh # Reserved Files # Variables # Installer pages !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES # Installer languages !insertmacro MUI_LANGUAGE English # Installer attributes OutFile javautilities.exe CRCCheck on XPStyle on ShowInstDetails show InstallDirRegKey HKLM "${REGKEY}" Path ShowUninstDetails show # Installer sections Section "!Java Utilities" SEC0000 StrCpy $9 $9\bin ReadRegStr $0 HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path Push $0 Push $9 Call StrStr Pop $R0 StrCmp $R0 "" 0 +3 StrCpy $0 "$0;$9" WriteRegExpandStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path $0 ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.java] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\.java "" java_auto_file ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\java_auto_file] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\java_auto_file "" "" ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\java_auto_file\shell] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\java_auto_file\shell "" open ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\java_auto_file\shell\Make] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\java_auto_file\shell\Make "" "" DeleteRegValue HKEY_LOCAL_MACHINE SOFTWARE\Classes\java_auto_file\shell\Make "" ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\java_auto_file\shell\Make\command] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\java_auto_file\shell\Make\command "" "$\"$WINDIR\makejava.bat$\" $\"%1$\"" ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.class] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\.class "" class_auto_file ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\class_auto_file] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\class_auto_file "" "" ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\class_auto_file\shell] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\class_auto_file\shell "" "" DeleteRegValue HKEY_LOCAL_MACHINE SOFTWARE\Classes\class_auto_file\shell "" ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\class_auto_file\shell\open] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\class_auto_file\shell\open "" "" DeleteRegValue HKEY_LOCAL_MACHINE SOFTWARE\Classes\class_auto_file\shell\open "" ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\class_auto_file\shell\open\command] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\class_auto_file\shell\open\command "" "$\"$WINDIR\runjava.bat$\" $\"%1$\"" ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.java] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\.jar "" jar_auto_file ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\java_auto_file] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\jar_auto_file "" "" ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\java_auto_file\shell] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\jar_auto_file\shell "" open ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\java_auto_file\shell\Make] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\jar_auto_file\shell\open "" "" DeleteRegValue HKEY_LOCAL_MACHINE SOFTWARE\Classes\jar_auto_file\shell\open "" ; Importing [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\java_auto_file\shell\Make\command] WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\jar_auto_file\shell\open\command "" "$\"$WINDIR\runjar.bat$\" $\"%1$\"" SetOutPath $WINDIR SetOverwrite on File makejava.bat File runjava.bat File runjar.bat SetOutPath "$PROGRAMFILES\Java Utilities" File javautilities.txt WriteRegStr HKLM "${REGKEY}\Components" "Java Utilities" 1 SectionEnd Section -post SEC0001 WriteRegStr HKLM "${REGKEY}" Path "$PROGRAMFILES\Java Utilities" WriteUninstaller "$PROGRAMFILES\Java Utilities\uninstall.exe" WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)" WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}" WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1 WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1 SectionEnd # Macro for selecting uninstaller sections !macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID Push $R0 ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}" StrCmp $R0 1 0 next${UNSECTION_ID} !insertmacro SelectSection "${UNSECTION_ID}" GoTo done${UNSECTION_ID} next${UNSECTION_ID}: !insertmacro UnselectSection "${UNSECTION_ID}" done${UNSECTION_ID}: Pop $R0 !macroend # Uninstaller sections Section /o "un.Java Utilities" UNSEC0000 Delete /REBOOTOK $INSTDIR\javautilities.txt Delete /REBOOTOK $WINDIR\runjava.bat Delete /REBOOTOK $WINDIR\makejava.bat Delete /REBOOTOK $WINDIR\runjar.bat DeleteRegKey HKEY_LOCAL_MACHINE SOFTWARE\Classes\java_auto_file\shell\Make\command DeleteRegKey HKEY_LOCAL_MACHINE SOFTWARE\Classes\java_auto_file\shell\Make DeleteRegKey /ifempty HKEY_LOCAL_MACHINE SOFTWARE\Classes\java_auto_file\shell WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\class_auto_file\shell\open\command "" "notepad.exe $\"%1$\"" WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Classes\.jar "" jarfile DeleteRegValue HKLM "${REGKEY}\Components" "Java Utilities" SectionEnd Section un.post UNSEC0001 DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Delete /REBOOTOK $INSTDIR\uninstall.exe DeleteRegValue HKLM "${REGKEY}" Path DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components" DeleteRegKey /IfEmpty HKLM "${REGKEY}" RmDir /REBOOTOK $INSTDIR SectionEnd # Installer functions Function .onInit InitPluginsDir FunctionEnd # Uninstaller functions Function un.onInit ReadRegStr $INSTDIR HKLM "${REGKEY}" Path !insertmacro SELECT_UNSECTION "Java Utilities" ${UNSEC0000} FunctionEnd ; StrStr ; input, top of stack = string to search for ; top of stack-1 = string to search in ; output, top of stack (replaces with the portion of the string remaining) ; modifies no other variables. ; ; Usage: ; Push "this is a long ass string" ; Push "ass" ; Call StrStr ; Pop $R0 ; ($R0 at this point is "ass string") Function StrStr Exch $R1 ; st=haystack,old$R1, $R1=needle Exch ; st=old$R1,haystack Exch $R2 ; st=old$R1,old$R2, $R2=haystack Push $R3 Push $R4 Push $R5 StrLen $R3 $R1 StrCpy $R4 0 ; $R1=needle ; $R2=haystack ; $R3=len(needle) ; $R4=cnt ; $R5=tmp loop: StrCpy $R5 $R2 $R3 $R4 StrCmp $R5 $R1 done StrCmp $R5 "" done IntOp $R4 $R4 + 1 Goto loop done: StrCpy $R1 $R2 "" $R4 Pop $R5 Pop $R4 Pop $R3 Pop $R2 Exch $R1 FunctionEnd