InstallDir "$PROGRAMFILES\test\" ;------------------------------------------------------------------------------ ; GetWinampInstPath ; ; takes no parameters ; returns with the winamp install directory on the stack (it will be ; an empty string if winamp is not detected). ; ; modifies no other variables ; ; Usage: ; Call GetWinampInstPath ; Pop $0 ; MessageBox MB_OK "Winamp installed at: $0" Function GetWinampInstPath Push $0 Push $1 Push $2 ReadRegStr $0 HKLM \ "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" \ "UninstallString" StrCmp $0 "" fin StrCpy $1 $0 1 0 ; get firstchar StrCmp $1 '"' "" getparent ; if first char is ", let's remove "'s first. StrCpy $0 $0 "" 1 StrCpy $1 0 rqloop: StrCpy $2 $0 1 $1 StrCmp $2 '"' rqdone StrCmp $2 "" rqdone IntOp $1 $1 + 1 Goto rqloop rqdone: StrCpy $0 $0 $1 getparent: ; the uninstall string goes to an EXE, let's get the directory. StrCpy $1 -1 gploop: StrCpy $2 $0 1 $1 StrCmp $2 "" gpexit StrCmp $2 "\" gpexit IntOp $1 $1 - 1 Goto gploop gpexit: StrCpy $0 $0 $1 StrCmp $0 "" fin IfFileExists $0\winamp.exe fin StrCpy $0 "" fin: Pop $2 Pop $1 Exch $0 FunctionEnd #====================================================================== #====================================================================== Function .onInit Call GetAppInstPath Pop $0 StrCmp $0 "" warn path_good warn: MessageBox MB_OK|MB_ICONSTOP "The program was not found.$\nPlease install blah blah or choose another folder." Push $INSTDIR Pop $0 path_good: StrCpy $INSTDIR $0 FunctionEnd #====================================================================== Section "" ; (default section) IfFileExists "$0\Templates\${t_name}" copyfile nocopyfile copyfile: CreateDirectory "$0\Templates_BackUp" CopyFiles "$0\Templates\*.*" "$0\Templates_BackUp" MessageBox MB_OK "Existing Templates moved to Templates_BackUp folder" nocopyfile: ;############# SetOutPath "$0\Templates" ; add files / whatever that need to be installed here. File /r "C:\test\*.*" SectionEnd ; end of default section ;############ Function .onInstSuccess MessageBox MB_OK "Congratulations, you have updated your templates." FunctionEnd ;############ ; eof