; Header Files ; not used in this case but handy when scaling up to multiple sections ; !include "Sections.nsh" !include "FileFunc.nsh" !include LogicLib.nsh ; common defines for Application !define APPVERSION "1.1.0.4" !define APPALT_VER "1_1_0_4" !define VERSIONMAJOR "1" !define VERSIONMINOR "1.0" !define APP "Poweroff" !define APP_ALT "Poweroff" !define APP_FILE "poweroff" ; common defines for Winamp-Plugin !define VERSION "1.0" !define ALT_VER "1_0" !define PLUG "Poweroff Winamp-Plugin" !define PLUG_ALT "Poweroff Winamp-Plugin" !define PLUG_FILE "gen_poweroff" ; use lzma compression SetCompressor lzma ; The name of the installer based on the filename and version Name "${APP} v${APPVERSION}" ; The file to write based on the filename and version OutFile "${APP_ALT}_v${APPALT_VER}.exe" ; you could alter it to output you plugin installers into a common location ; to make it easier to maintain them ; OutFile "../_Installers/${APP_ALT}_v${APPALT_VER}.exe" ; The default installation directory InstallDir $PROGRAMFILES\Poweroff InstProgressFlags smooth ; The text to prompt the user to enter a directory DirText "Bitte Installationspfad auswählen:" ; automatically close the installer when done. AutoCloseWindow true ; adds xp style support XPStyle on ; hide the "show details" box ShowInstDetails nevershow ;Pages PageEx directory DirText "Bitte Installationspfad auswählen:" Caption "Poweroff-Installationspfad" PageExEnd ; enable this line if you have extra sections and want to choose what's ; installed ;Page components Page instfiles Var appinstalldone Var ANOTHER_DIR ; The stuff to install Section "" SetOverwrite on #MessageBox MB_OK '$INSTDIR' SetOutPath "$INSTDIR" ; File to extract File "${APP_FILE}.exe" #File "Poweroff Winamp-Plugin.exe" ; if you're script is in the project folder then the following file path is ; likely to apply otherwise just alter the path as needed ; File "Release\${APP_FILE}.dll" CreateShortCut "$DESKTOP\Poweroff.lnk" "$INSTDIR\${APP_FILE}.exe" CreateShortCut "$SMPROGRAMS\${APP_ALT}\${APP_ALT} - Uninstall.lnk" "$INSTDIR\uninstall.exe" CreateShortCut "$SMPROGRAMS\${APP_ALT}\${APP_ALT}.lnk" "$INSTDIR\${APP_FILE}.exe" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Poweroff" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Poweroff" "DisplayName" "Poweroff" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Poweroff" "InstallLocation" "$\"$INSTDIR$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Poweroff" "Publisher" "blackcoder" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Poweroff" "VersionMajor" "${VERSIONMAJOR}" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Poweroff" "VersionMinor" "${VERSIONMINOR}" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Poweroff" "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Poweroff" "NoRepair" 1 # create the uninstaller writeUninstaller "$INSTDIR\uninstall.exe" SetOverwrite off StrCpy $appinstalldone "1" SectionEnd PageEx directory DirText "Bitte den Winamp-Pfad auswählen (Sie können fortfahren, wenn Winamp erkannt wurde):" Caption "Winamp-Plugin Installationspfad" DirVar $ANOTHER_DIR PageExEnd Page instfiles Section "Plugininstall" SetOverwrite on # Installation des Winamp-Plugins ; attempt to close Winamp if it's running Call CloseWinamp ; add a small delay to allow any file operations to happen once Winamp ; is closed Sleep 100 #MessageBox MB_OK 'Plugininstall: $ANOTHER_DIR' SetOutPath $ANOTHER_DIR\Plugins ; File to extract File "${PLUG_FILE}.dll" SetOverwrite off SectionEnd Function CloseWinamp Push $5 loop: FindWindow $5 "Winamp v1.x" IntCmp $5 0 done SendMessage $5 16 0 0 Sleep 100 Goto loop done: Pop $5 FunctionEnd Function un.CloseWinamp Push $5 loop: FindWindow $5 "Winamp v1.x" IntCmp $5 0 done SendMessage $5 16 0 0 Sleep 100 Goto loop done: Pop $5 FunctionEnd var plugindir # uninstaller section start Section "uninstall" # first, delete the uninstaller Delete "$INSTDIR\uninstall.exe" # Desktopverknüpfung löschen #MessageBox MB_OK "$DESKTOP\${APP_ALT}.lnk" Delete "$DESKTOP\${APP_ALT}.lnk" # Poweroff.exe löschen Delete "$INSTDIR\${APP_FILE}.exe" # Installationsordner löschen StrCpy $0 "$INSTDIR" Call un.DeleteDirIfEmpty # Eintrag unter Add/Modify löschen (Systemsteuerung/Software) DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Poweroff" # Ist nötig, damit auch wirklich die Einträge im Startmenü gelöscht werden (erforderlich ab Vista). SetShellVarContext all # second, remove the link from the start menu Delete "$SMPROGRAMS\${APP_ALT}\${APP_ALT}.lnk" Delete "$SMPROGRAMS\${APP_ALT}\${APP_ALT} - Uninstall.lnk" StrCpy $0 "$SMPROGRAMS\${APP_ALT}" Call un.DeleteDirIfEmpty # Winamp-Plugin deinstallieren ReadRegStr $plugindir HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" "UninstallString" # Anführungsstriche aus String entfernen. Push $plugindir Call un.GetInQuotes Pop $plugindir ; = quotes ${GetParent} $plugindir $plugindir ; attempt to close Winamp if it's running Call un.CloseWinamp ; add a small delay to allow any file operations to happen once Winamp ; is closed Sleep 100 Delete $plugindir\Plugins\gen_poweroff.dll SectionEnd # uninstaller section end Function un.DeleteDirIfEmpty FindFirst $R0 $R1 "$0\*.*" strcmp $R1 "." 0 NoDelete FindNext $R0 $R1 strcmp $R1 ".." 0 NoDelete ClearErrors FindNext $R0 $R1 IfErrors 0 NoDelete FindClose $R0 Sleep 1000 RMDir "$0" NoDelete: FindClose $R0 FunctionEnd Function .onInstSuccess MessageBox MB_OK \ '${APP} wurde installiert.' \ IDNO end end: FunctionEnd Function .onInit ReadRegStr $ANOTHER_DIR HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" "UninstallString" # Anführungsstriche aus String entfernen. Push $ANOTHER_DIR Call GetInQuotes Pop $ANOTHER_DIR ; = quotes ${GetParent} $ANOTHER_DIR $ANOTHER_DIR # Wenn aus der Registrie nichts gelesen werden konnte, dann Standardpfad einsetzen. ${If} $ANOTHER_DIR == "" StrCpy $ANOTHER_DIR "$PROGRAMFILES\Winamp" ${EndIf} FunctionEnd ; here we check to see if this a valid location ie is there a Winamp.exe ; in the directory? Function .onVerifyInstDir # Wenn appinstall 1 ist, dann wurde das Programm schon installiert und jetzt wird der Pfad fürs Winamp-Plugin überprüft. ${If} $appinstalldone == "1" ;Check for Winamp installation IfFileExists $ANOTHER_DIR\Winamp.exe Good Abort ${EndIf} Good: FunctionEnd # Anführungsstriche aus dem String entfernen Function GetInQuotes Exch $R0 Push $R1 Push $R2 Push $R3 StrCpy $R2 -1 IntOp $R2 $R2 + 1 StrCpy $R3 $R0 1 $R2 StrCmp $R3 "" 0 +3 StrCpy $R0 "" Goto Done StrCmp $R3 '"' 0 -5 IntOp $R2 $R2 + 1 StrCpy $R0 $R0 "" $R2 StrCpy $R2 0 IntOp $R2 $R2 + 1 StrCpy $R3 $R0 1 $R2 StrCmp $R3 "" 0 +3 StrCpy $R0 "" Goto Done StrCmp $R3 '"' 0 -5 StrCpy $R0 $R0 $R2 Done: Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd # Anführungsstriche aus dem String entfernen (für den Uninstaller). Function un.GetInQuotes Exch $R0 Push $R1 Push $R2 Push $R3 StrCpy $R2 -1 IntOp $R2 $R2 + 1 StrCpy $R3 $R0 1 $R2 StrCmp $R3 "" 0 +3 StrCpy $R0 "" Goto Done StrCmp $R3 '"' 0 -5 IntOp $R2 $R2 + 1 StrCpy $R0 $R0 "" $R2 StrCpy $R2 0 IntOp $R2 $R2 + 1 StrCpy $R3 $R0 1 $R2 StrCmp $R3 "" 0 +3 StrCpy $R0 "" Goto Done StrCmp $R3 '"' 0 -5 StrCpy $R0 $R0 $R2 Done: Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd