Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Аватара для Комсомолец

Ветеран


Автор проектов


Сообщения: 1558
Благодарности: 228

Профиль | Сайт | Отправить PM | Цитировать


hb860, немного поправил скрипт. Может пригодится, но мне так удобнее. )) посмотри.
читать дальше »
Код: Выделить весь код
;Text/Registry definitions
!define PRODUCT_NAME "AIMP2"
!define PRODUCT_VERSION "2.5.0.306"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define BRANDING "By hb860"

;icons indexes definition
!define idxWAV 0
!define idxMP3 1
!define idxOGG 2
!define idxWMA 3
!define idxAUDIO 4
!define idxMOD 5
!define idxFLAC 6
!define idxMPC 7
!define idxSKIN 8
!define idxPLAYLIST 9

; MUI 1.67 compatible ------
!include "MUI.nsh"
!include "FileFunc.nsh"
!include "LogicLib.nsh"
SetCompressor /SOLID lzma
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\aimp.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-blue-full.ico"
!define MUI_COMPONENTSPAGE_NODESC 
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS 
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "Russian"

;service macroses
!insertmacro GetOptions
!insertmacro RefreshShellIcons

;Common directives
BrandingText "${BRANDING}"
Name "${PRODUCT_NAME}"
Caption "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "${PRODUCT_NAME}-${PRODUCT_VERSION}.exe"
InstallDir "$PROGRAMFILES\AIMP2"
ShowInstDetails show
ShowUninstDetails show

;installation types
InstType "Полная"
InstType "Сокращенная"
InstType "Минимальная"

;variables section
Var SkinFile
Var IconFile
Var IconFileName
Var OpenCommand
Var ProfilePath
Var MultiUser
Var MultiUserCmdValue

;custom filetype registration function
!macro RegisterExtension extenstion /*ContentType PerceivedType*/ ClassName ClassStrDefault IconIndex
  WriteRegStr HKCR "${extenstion}" "" "${ClassName}"
  ;WriteRegStr HKCR "${extenstion}" "PerceivedType" "${PerceivedType}"
  ;WriteRegStr HKCR "${extenstion}" "Content Type" "${ContentType}"
  
  WriteRegStr HKCR "${ClassName}" "" "${ClassStrDefault}"
  WriteRegStr HKCR "${ClassName}\CLSID" "" "{0041494D-5032-4472-6F70-546172676574}"
  WriteRegStr HKCR "${ClassName}\DefaultIcon" "" "$IconFile,${IconIndex}"
  WriteRegStr HKLM "${ClassName}\shell\open" "" "Открыть в AIMP2"
  WriteRegStr HKCR "${ClassName}\shell\open\command" "" "$OpenCommand"
  WriteRegStr HKCR "${ClassName}\shell\open\DropTarget" "CLSID" "{0041494D-5032-4472-6F70-546172676574}"
!macroend



;sections
Section "!${PRODUCT_NAME}" 
  SectionIn 1 2 3 RO
  StrCpy $ProfilePath "$INSTDIR\Data\Profile"
  SetOutPath "$INSTDIR\"
   File /r "C:\AIMP2\*.*"
	WriteUninstaller "$OUTDIR\uninst.exe"
	WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
	WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$OUTDIR\aimp2.exe"
	WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$OUTDIR\uninst.exe"
	WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
SectionEnd

Section /o "Отдельные настройки на каждого пользователя"
	SectionIn 1
	;Very important be sure what SetShellVarContext has CURRENT value here
	StrCpy $MultiUser 1
SectionEnd

;=========================================================================================================================
SectionGroup /e "Дополнения"
	
	Section "Скины" 
		SectionIn 1 2
		SetOutPath "$INSTDIR\Skins"
		File "C:\AIMP2\Skins\*.*"
	SectionEnd

	Section "Иконки типов файлов" 
		SectionIn 1 2
		SetOutPath "$INSTDIR\Icons"
		File "C:\AIMP2\Icons\*.*"
	SectionEnd
SectionGroupEnd	

;=========================================================================================================================
SectionGroup /e "Ярлыки"
	Section "В меню Пуск" 
		SectionIn 1 2 3
		SetShellVarContext all
		CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
		CreateShortCut  "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\aimp2.exe"
		CreateShortCut  "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} Advanced Tag Editor.lnk" "$INSTDIR\AIMP2t.exe"
		CreateShortCut  "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} Audio Converter.lnk" "$INSTDIR\AIMP2c.exe"
		CreateShortCut  "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} Audio Recorder.lnk" "$INSTDIR\AIMP2r.exe"
		CreateShortCut  "$SMPROGRAMS\${PRODUCT_NAME}\Удалить ${PRODUCT_NAME}.lnk" "$INSTDIR\uninst.exe"
	SectionEnd
	Section "На рабочем столе" 
		SectionIn 1
		IfSilent +3
		SetShellVarContext all
		CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\aimp2.exe"
	SectionEnd
	Section "В панели быстрого запуска" 
		SectionIn 1 2
		SetShellVarContext all
		CreateShortCut "$QUICKLAUNCH\${PRODUCT_NAME}.lnk" "$INSTDIR\aimp2.exe"
	SectionEnd
SectionGroupEnd	

;=========================================================================================================================
SectionGroup /e "Ассоциации файлов"
	Section "-GetIconsDll"
		SectionIn 1 2 3
		${GetOptions} $CMDLINE "/ICONS=" $IconFileName
		StrCmp $IconFileName "" EmptyIconFile
		IfFileExists "$INSTDIR\Icons\$IconFileName" EndSection IconFileNotExists
			
		IconFileNotExists:
			StrCpy $IconFileName ""
		EmptyIconFile:
			StrCpy $IconFileName "aimp2.dll"
		EndSection:
			StrCpy $IconFile "$INSTDIR\Icons\$IconFileName"
			StrCpy $OpenCommand "$INSTDIR\AIMP2.exe $\"%1$\""
	SectionEnd
	
	Section "Контекстое меню проводника"
		SectionIn 1 2
		RegDLL  "$INSTDIR\System\aimp_shell.dll"
	SectionEnd
	
	Section "AAC"
		SectionIn 1 2
		!insertmacro RegisterExtension ".aac" "AIMP.AAC" "AIMP2: AAC" ${idxAUDIO}
	SectionEnd
	
	Section "ACS2"
		SectionIn 1 2
		!insertmacro RegisterExtension ".acs2" "AIMP.ACS2" "AIMP2: ACS2" ${idxSKIN}
	SectionEnd
	
	Section "AIF"
		SectionIn 1 2
		!insertmacro RegisterExtension ".aif" "AIMP.AIF" "AIMP2: AIF" ${idxAUDIO}
	SectionEnd	
	
	Section "AIFF"
		SectionIn 1 2
		!insertmacro RegisterExtension ".aiff" "AIMP.AIFF" "AIMP2: AIFF" ${idxAUDIO}
	SectionEnd		
	
	Section "APE"
		SectionIn 1 2
		!insertmacro RegisterExtension ".ape" "AIMP.APE" "AIMP2: APE" ${idxAUDIO}
	SectionEnd	

	Section "AUDIOCD"
		SectionIn 1 2 3
		!insertmacro RegisterExtension "AudioCD" "AIMP.AUDIOCD" "AIMP2: AUDIOCD" ${idxAUDIO}
	SectionEnd		
	
	Section "CDA"
		SectionIn 1 2
		!insertmacro RegisterExtension ".cda" "AIMP.CDA" "AIMP2: CDA" ${idxAUDIO}
	SectionEnd		

	Section "CUE"
		SectionIn 1 2
		!insertmacro RegisterExtension ".cue" "AIMP.CUE" "AIMP2: CUE" ${idxPLAYLIST}
	SectionEnd

	Section "FLAC"
		SectionIn 1 2
		!insertmacro RegisterExtension ".flac" "AIMP.FLAC" "AIMP2: FLAC" ${idxFLAC}
	SectionEnd	

	Section "IT"
		SectionIn 1 2
		!insertmacro RegisterExtension ".it" "AIMP.IT" "AIMP2: IT" ${idxMOD}
	SectionEnd
	
	Section "M3U"
		SectionIn 1 2 3
		!insertmacro RegisterExtension ".m3u" "AIMP.M3U" "AIMP2: M3U" ${idxPLAYLIST}
	SectionEnd	
	
	Section "M3U8"
		SectionIn 1 2
		!insertmacro RegisterExtension ".m3u8" "AIMP.M3U8" "AIMP2: M3U8" ${idxPLAYLIST}
	SectionEnd	
	
	Section "MID"
		SectionIn 1 2
		!insertmacro RegisterExtension ".mid" "AIMP.MID" "AIMP2: MID" ${idxAUDIO}
	SectionEnd	

	Section "MO3"
		SectionIn 1 2
		!insertmacro RegisterExtension ".mo3" "AIMP.MO3" "AIMP2: MO3" ${idxMOD}
	SectionEnd	
	
	Section "MOD"
		SectionIn 1 2
		!insertmacro RegisterExtension ".mod" "AIMP.MOD" "AIMP2: MOD" ${idxMOD}
	SectionEnd	

	Section "MP1"
		SectionIn 1 2
		!insertmacro RegisterExtension ".mp1" "AIMP.MP1" "AIMP2: MP1" ${idxMP3}
	SectionEnd

	Section "MP2"
		SectionIn 1 2
		!insertmacro RegisterExtension ".mp2" "AIMP.MP2" "AIMP2: MP2" ${idxMP3}
	SectionEnd	

	Section "MP3"
		SectionIn 1 2 3
		!insertmacro RegisterExtension ".mp3" "AIMP.MP3" "AIMP2: MP3" ${idxMP3}
	SectionEnd		

	Section "MPC"
		SectionIn 1 2
		!insertmacro RegisterExtension ".mpc" "AIMP.MPC" "AIMP2: MPC" ${idxMPC}
	SectionEnd

	Section "MTM"
		SectionIn 1 2
		!insertmacro RegisterExtension ".mtm" "AIMP.MTM" "AIMP2: MTM" ${idxMOD}
	SectionEnd

	Section "OGG"
		SectionIn 1 2 3
		!insertmacro RegisterExtension ".ogg" "AIMP.OGG" "AIMP2: OGG" ${idxOGG}
	SectionEnd

	Section "PLC"
		SectionIn 1 2 3
		!insertmacro RegisterExtension ".plc" "AIMP.PLC" "AIMP2: PLC" ${idxPLAYLIST}
	SectionEnd

	Section "PLS"
		SectionIn 1 2 3
		!insertmacro RegisterExtension ".pls" "AIMP.PLS" "AIMP2: PLS" ${idxPLAYLIST}
	SectionEnd

	Section "S3M"
		SectionIn 1 2
		!insertmacro RegisterExtension ".s3m" "AIMP.S3M" "AIMP2: S3M" ${idxMOD}
	SectionEnd

	Section "UMX"
		SectionIn 1 2
		!insertmacro RegisterExtension ".umx" "AIMP.UMX" "AIMP2: UMX" ${idxMOD}
	SectionEnd	
	
	Section "WAV"
		SectionIn 1 2 3
		!insertmacro RegisterExtension ".wav" "AIMP.WAV" "AIMP2: WAV" ${idxWAV}
	SectionEnd	
	
	Section "WMA"
		SectionIn 1 2 3
		!insertmacro RegisterExtension ".wma" "AIMP.WMA" "AIMP2: WMA" ${idxWMA}
	SectionEnd	

	Section "WV"
		SectionIn 1 2
		!insertmacro RegisterExtension ".wv" "AIMP.WV" "AIMP2: WV" ${idxAUDIO}
	SectionEnd
	
	Section "XM"
		SectionIn 1 2
		!insertmacro RegisterExtension ".xm" "AIMP.XM" "AIMP2: XM" ${idxMOD}
	SectionEnd	
	Section "-RefreshIcons"
		SectionIn 1 2 3
		${RefreshShellIcons}
	SectionEnd
SectionGroupEnd	
;=========================================================================================================================
Section "-PostinstallProfileProcessing"
	;here we must set current user constats context
	SetShellVarContext current

	;common INI settings
	CreateDirectory "$INSTDIR\DATA"
	WriteINIStr "$INSTDIR\DATA\AIMP.INI" System DefaultLang russian.lng
	WriteINIStr "$INSTDIR\DATA\AIMP.INI" System Version 2500
	
	${GetOptions} $CMDLINE "/MULTIUSER=" $MultiUserCmdValue
	StrCmp $MultiUserCmdValue "" +2
	StrCpy $MultiUser $MultiUserCmdValue
	
	StrCmp $MultiUser 1 PerUserCFG OneUserCFG
	
	PerUserCFG:
		WriteINIStr "$INSTDIR\DATA\AIMP.INI" System UserMode 1
		StrCpy $ProfilePath "$APPDATA\AIMP"
		CreateDirectory "$ProfilePath"
		Goto WriteCFG
	OneUserCFG:	
		WriteINIStr "$INSTDIR\DATA\AIMP.INI" System UserMode 0
		CreateDirectory "$INSTDIR\DATA\Profile" 
		Goto WriteCFG
	WriteCFG:
		SetOutPath "$ProfilePath"
		File /nonfatal /r "c:\Aimp2\DATA\Profile\"
		
		IfFileExists "$ProfilePath\AIMP2.INI" EndSection
		WriteINIStr "$ProfilePath\AIMP2.INI" System LangFile russian.lng ;язык по умолчанию для плеера
		WriteINIStr "$ProfilePath\AIMP2r.INI" System LangFile russian.lng ;язык по умолчанию для рекордера
		WriteINIStr "$ProfilePath\AIMP2c.INI" System LangFile russian.lng ;язык по умолчанию для конвертера
		WriteINIStr "$ProfilePath\AIMP2t.INI" System LangFile russian.lng ;язык по умолчанию для таггера	
	EndSection:	
		${GetOptions} $CMDLINE "/SKIN=" $SkinFile
		StrCmp $SkinFile "" +2
		WriteINIStr "$ProfilePath\AIMP2.INI" Skins DefaultSkin $SkinFile	;скин		
		WriteINIStr "$ProfilePath\AIMP2.INI" Skins ICL $IconFileName	;скин
SectionEnd

Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "Удаление программы $(^Name) было успешно завершено."
FunctionEnd

Function un.onInit
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Вы уверены в том, что желаете удалить $(^Name) и все компоненты программы?" IDYES +2
  Abort
FunctionEnd

Section Uninstall
  UnRegDLL "$INSTDIR\System\aimp_shell.dll"
  ExecWait '$INSTDIR\aimp2.exe /REG=U'
  RMDir /r "$INSTDIR\"
  SetShellVarContext all
  RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}"
  Delete "$DESKTOP\${PRODUCT_NAME}.LNK"
  Delete "$QUICKLAUNCH\${PRODUCT_NAME}.LNK"
  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  SetAutoClose true
SectionEnd

-------
Для того, чтобы узнать, что такое рекурсия - необходимо узнать, что такое рекурсия. :)

http://forum.oszone.net/image.php?type=sigpic&userid=69953&dateline=1440353086


Отправлено: 11:18, 17-10-2008 | #49