迅雷 NSIS 安装脚本开源

2010-08-28 10:53:29来源:西部e网作者:

!define PRODUCT_NAME "迅雷"
!define PRODUCT_VERSION "V5.7.9.486"
!define PRODUCT_PUBLISHER "迅雷网络技术有限公司"
!define PRODUCT_WEB_SITE "http://www.xunlei.com"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\Thunder.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
SetCompressor lzma
ReserveFile          "Head.bmp"
ReserveFile          "Left.bmp"
ReserveFile          "xunlei.ini"
!define IOS          "ioSpecial.ini"
Var INI
!include "MUI.nsh"
!include "UsefulLib.nsh"
!define MUI_ABORTWARNING
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT
!define MUI_HEADERIMAGE_BITMAP "Head.bmp"
!define MUI_WELCOMEFINISHPAGE_BITMAP "Left.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "Left.bmp"
!define MUI_WELCOMEPAGE_TITLE "迅雷V5.7.9.486  特别版"
!define MUI_ICON "Thunder.ico"
!define MUI_UNICON "Thunder.ico"
!define MUI_COMPONENTSPAGE_SMALLDESC
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "License.txt"
Page custom Choose
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_PAGE_CUSTOMFUNCTION_PRE   FinishPagePre
!define MUI_PAGE_CUSTOMFUNCTION_SHOW  FinishPageShow
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE FinishPageLeave
!define MUI_FINISHPAGE_RUN "$INSTDIR\Thunder.exe"
!define MUI_FINISHPAGE_SHOWREADME_TEXT "查看更新历史"
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\Program\Whatsnew.txt"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
VIProductVersion "5.7.9.486"
VIAddVersionKey /LANG=2052 "ProductName" "迅雷5特别版"
VIAddVersionKey /LANG=2052 "Comments" "请仔细阅读许可协议"
VIAddVersionKey /LANG=2052 "CompanyName" "Thunder Networking Technologies,LTD"
VIAddVersionKey /LANG=2052 "LegalCopyright" "2003-2008"
VIAddVersionKey /LANG=2052 "FileDescription" "xunlei"
VIAddVersionKey /LANG=2052 "FileVersion" "5.7.9.486"
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Thunder5"
InstallDir "$PROGRAMFILES\Thunder"
InstallDirRegKey HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
ShowInstDetails hide
ShowUnInstDetails hide
BrandingText "xunlei.Com"
Section "-clean"
  DeleteRegKey   HKCU  "Software\Microsoft\Internet Explorer\MenuExt\&使用迅雷下载"
  DeleteRegKey   HKCU  "Software\Microsoft\Internet Explorer\MenuExt\&使用迅雷下载全部链接"
DeleteRegKey  HKLM "SOFTWARE\Microsoft\Internet Explorer\Extensions\{0062C9BD-B349-40DE-91A0-755F37ACD559}"
SectionEnd
Section "基本功能(必需)" SECBasic
SectionIn ro
SetDetailsPrint textonly
DetailPrint "正在安装基本功能(必需)..."
SetDetailsPrint listonly
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File  "Thunder\Thunder.exe"
  SetOutPath "$INSTDIR\Program"
  File /r "Thunder\Program\*.*"
  ExecShell open "$INSTDIR\Program\SetupHelper.exe" "/exit_thunder5"
  ExecShell open "$INSTDIR\Program\SetupHelper.exe" "/close_firewall"
  SetOutPath "$INSTDIR\Languages"
  File /r "Thunder\Languages\*.*"
  SetOutPath "$INSTDIR\Plugins\XLSafeHost"
  File /r "Thunder\Plugins\XLSafeHost\*.*"
  SetOutPath "$INSTDIR\ComDlls"
  SetOverwrite try
  File /r "Thunder\ComDlls\*.*"
  SetOutPath "$INSTDIR\Profiles"
  File "UserConfig.ini"
  SetOutPath "$INSTDIR\Components"
  File /r "Thunder\Components\*.*"
  RegDLL "$INSTDIR\Components\DownAndPlay\DapPlayer.dll"
  RegDLL "$INSTDIR\Components\DownAndPlay\xlsf.dll"
  RegDLL "$INSTDIR\Components\DownAndPlay\DapCtrl.dll"
  SetOutPath "$SYSDIR"
  File "msvcp60.dll"
  Exec '"$INSTDIR\Program\Thunder5.exe" /installaddin:{76F61D18-C813-432E-BC7A-A41A45D04113}|迅雷安全下载组件|..\Components\security\ThunderSafe.dll'
SectionEnd
Section "迅雷看看" SECKankan
ReadIniStr $0 "$INI" "Field 6" "state"
${If} $0 == 1
SetDetailsPrint textonly
DetailPrint "正在安装迅雷看看..."
SetDetailsPrint listonly
  SetOutPath "$INSTDIR\Components\KanKan"
  File /r "KanKan\*.*"
  RegDLL "$INSTDIR\Components\KanKan\XAFilter.ax"
  RegDLL "$INSTDIR\Components\KanKan\PPlayer.dll"
  RegDLL "$INSTDIR\Components\KanKan\Xdrm.dll"
  RegDLL "$INSTDIR\Components\KanKan\XmvSource.dll"
  RegDLL "$INSTDIR\Components\KanKan\XPlayer.dll"
${EndIf}
SectionEnd
Section "狗狗搜索" SECGouGouTop
ReadIniStr $5 "$INI" "Field 5" "state"
${If} $5 == 1
SetDetailsPrint textonly
DetailPrint "正在安装狗狗搜索排行..."
SetDetailsPrint listonly
  SetOutPath "$INSTDIR\Components\Search"
  File /r "Search\*.*"
  SetOutPath "$INSTDIR\Plugins\GouGouTop"
  File /r "GouGouTop\*.*"
${EndIf}
SectionEnd
Section "创建快捷方式" SecDesktop
ReadIniStr $4 "$INI" "Field 4" "state"
${If} $4 == 1
SetDetailsPrint textonly
DetailPrint "正在创建快捷方式..."
SetDetailsPrint listonly
  CreateShortCut "$DESKTOP\迅雷5.lnk" "$INSTDIR\Thunder.exe"
  CreateDirectory "$SMPROGRAMS\迅雷"
  CreateShortCut "$SMPROGRAMS\迅雷\启动迅雷5.lnk" "$INSTDIR\Thunder.exe"
  CreateShortCut "$SMPROGRAMS\迅雷\更新信息.lnk" "$INSTDIR\Program\Whatsnew.txt"
  CreateShortCut "$SMPROGRAMS\迅雷\卸载迅雷5.lnk" "$INSTDIR\uninst.exe"
${EndIf}
SectionEnd
Section "-修复视频缓存文件夹" Vol_cache
WriteRegStr HKLM "SOFTWARE\Thunder Network\ThunderOem\thunder_backwnd" "Cache" "$APPDATA\vod_cache_data\"
SectionEnd
Section "-Regedit"
  SetDetailsPrint textonly
  DetailPrint "正在添加注册表信息..."
  SetDetailsPrint none
  WriteRegStr   HKLM "SOFTWARE\Thunder Network\ThunderOem\thunder_backwnd" "Path" "$INSTDIR\Thunder.exe"
WriteRegStr   HKLM "SOFTWARE\Thunder Network\ThunderOem\thunder_backwnd" "Version" "5.7.9.486"
WriteRegStr   HKCU "Software\Microsoft\Internet Explorer\MenuExt\使用迅雷下载" "" "$INSTDIR\Program\geturl.htm"
WriteRegDWORD HKCU "Software\Microsoft\Internet Explorer\MenuExt\使用迅雷下载" "Contexts" 0x00000022
WriteRegStr   HKCU "Software\Microsoft\Internet Explorer\MenuExt\使用迅雷下载全部链接" "" "$INSTDIR\Program\getallurl.htm"
WriteRegDWORD HKCU "Software\Microsoft\Internet Explorer\MenuExt\使用迅雷下载全部链接" "Contexts" 0x000000f3
  WriteRegStr   HKLM "SOFTWARE\Microsoft\Internet Explorer\Extensions\{09BA8F6D-CB54-424B-839C-C2A6C8E6B436}" "ButtonText" "迅雷5"
WriteRegStr   HKLM "SOFTWARE\Microsoft\Internet Explorer\Extensions\{09BA8F6D-CB54-424B-839C-C2A6C8E6B436}" "Exec" "$INSTDIR\Thunder.exe"
WriteRegStr   HKLM "SOFTWARE\Microsoft\Internet Explorer\Extensions\{09BA8F6D-CB54-424B-839C-C2A6C8E6B436}" "Icon" "$INSTDIR\Program\Thunder.ico"
WriteRegStr   HKLM "SOFTWARE\Microsoft\Internet Explorer\Extensions\{09BA8F6D-CB54-424B-839C-C2A6C8E6B436}" "HotIcon" "$INSTDIR\Program\Thunder.ico"
WriteRegStr   HKLM "SOFTWARE\Microsoft\Internet Explorer\Extensions\{09BA8F6D-CB54-424B-839C-C2A6C8E6B436}" "MenuStatusBar" "迅雷5"
WriteRegStr   HKLM "SOFTWARE\Microsoft\Internet Explorer\Extensions\{09BA8F6D-CB54-424B-839C-C2A6C8E6B436}" "MenuText" "迅雷5"
WriteRegStr   HKLM "SOFTWARE\Microsoft\Internet Explorer\Extensions\{09BA8F6D-CB54-424B-839C-C2A6C8E6B436}" "CLSID" "{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}"
WriteRegStr   HKLM "SOFTWARE\Microsoft\Internet Explorer\Extensions\{09BA8F6D-CB54-424B-839C-C2A6C8E6B436}" "Default Visible" "Yes"
SectionEnd
Section -Post
  WriteUninstaller "$INSTDIR\uninst.exe"
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\Thunder.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\Thunder.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 Uninstall
SetDetailsPrint textonly
DetailPrint "正在卸载$(^Name)..."
SetDetailsPrint none
  Delete "$INSTDIR\uninst.exe"
  ExecWait  '"$INSTDIR\Program\SetupHelper.exe" /exit_thunder5'
  ExecWait  '"$INSTDIR\Program\SetupHelper.exe" /delete_bho'
  ExecWait  '"$INSTDIR\Program\SetupHelper.exe" /close_firewall'
  ExecWait  '"$INSTDIR\Program\LanguageSetter.exe" fromfile|-1'
  UnRegDLL "$INSTDIR\Components\KanKan\XAFilter.ax"
  UnRegDLL "$INSTDIR\Components\KanKan\PPlayer.dll"
  UnRegDLL "$INSTDIR\Components\KanKan\Xdrm.dll"
  UnRegDLL "$INSTDIR\Components\KanKan\XmvSource.dll"
  UnRegDLL "$INSTDIR\Components\KanKan\XPlayer.dll"
  UnRegDLL "$INSTDIR\Components\DownAndPlay\DapPlayer.dll"
  UnRegDLL "$INSTDIR\Components\DownAndPlay\xlsf.dll"
  UnRegDLL "$INSTDIR\Components\DownAndPlay\DapCtrl.dll"
  UnRegDLL "$INSTDIR\ComDlls\TDAtOnce.dll"
  UnRegDLL "$INSTDIR\ComDlls\ThunderAgent.dll"
  UnRegDLL "$INSTDIR\ComDlls\XunLeiBHO.dll"
  Delete "$INSTDIR\Thunder.exe"
  Delete "$DESKTOP\迅雷5.lnk"
  Delete "$SMPROGRAMS\迅雷\迅雷5 卸载.lnk"
  Delete "$SMPROGRAMS\迅雷\迅雷5.lnk"
  RMDir /r  "$SMPROGRAMS\迅雷"
  RMDir /r  "$INSTDIR\Skins"
  RMDir /r  "$INSTDIR\Languages"
  RMDir /r /REBOOTOK "$INSTDIR\TDTmp"
  RMDir /r /REBOOTOK "$INSTDIR\Program"
  RMDir /r /REBOOTOK "$INSTDIR\Components"
  RMDir /r /REBOOTOK "$INSTDIR\ComDlls"
  RMDir /r /REBOOTOK "$INSTDIR\Plugins"
  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
  DeleteRegKey HKCR "bittorrent\shell\open\command"
  DeleteRegKey HKCR "bittorrent\shell\open"
  DeleteRegKey HKCR "bittorrent\shell"
  DeleteRegKey HKCR "bittorrent\DefaultIcon"
  DeleteRegKey HKCR "bittorrent"
  DeleteRegKey HKCU "Software\Microsoft\Internet Explorer\MenuExt\使用迅雷下载全部链接"
  DeleteRegKey HKCU "Software\Microsoft\Internet Explorer\MenuExt\使用迅雷下载"
  DeleteRegKey HKLM "SOFTWARE\Thunder Network\ThunderOem\thunder_backwnd"
  DeleteRegKey HKLM "SOFTWARE\Thunder Network\ThunderOem"
  DeleteRegKey HKLM "SOFTWARE\Thunder Network"
  System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "迅雷5 卸载完成。$\r$\r有些内容不能被删除。您可以手工删除它们。"
  SetAutoClose true
SectionEnd
Function .onInit
   InitPluginsDir
   File "/oname=$PLUGINSDIR\xunlei.ini" "xunlei.ini"
   GetTempFileName $INI $PLUGINSDIR
   File /oname=$INI "xunlei.ini"
  
!addplugindir "${NSISDIR}\Plugins"
  FindProcDLL::FindProc "Thunder5.exe"
   StrCmp $R0 1 +1 +6
     MessageBox MB_ICONINFORMATION|MB_ABORTRETRYIGNORE "检测到 迅雷 正在运行!忽略:强制安装;终止:退出安装程序!" /SD IDABORT IDRETRY Retry IDIGNORE Ignore
   Abort
  Retry:
   Goto -4
  Ignore:
   Goto +1
    KillProcDLL::KillProc "Thunder5.exe"
FunctionEnd
Function  Choose
  InstallOptions::initDialog /NOUNLOAD "$INI"
!insertmacro MUI_HEADER_TEXT "选定使用环境"  "选者使用环境,获得推荐的安全配置,以更好的保护帐号安全."
    ReadINIStr $0 "$INI" "Field 1" "HWND"
    CreateFont $R2 "宋体" 9 700
    SendMessage $0 ${WM_SETFONT} $R2 0
    SetCtlColors $0 /BRANDING  '0x009300' ''
   
    ReadINIStr $0 "$INI" "Field 5" "HWND"
    SetCtlColors $0 0x000000 0xFFFFFF
    ReadINIStr $0 "$INI" "Field 6" "HWND"
    SetCtlColors $0 0x000000 0xFFFFFF
    ReadINIStr $0 "$INI" "Field 7" "HWND"
    SetCtlColors $0 0x000000 0xFFFFFF
  InstallOptions::show
FunctionEnd
Function  FinishPagePre
WriteINIStr "$PLUGINSDIR\ioSpecial.ini" "Settings" "NumFields" "6"
WriteINIStr "$PLUGINSDIR\${IOS}" "Field 6" "Type" "CheckBox"
WriteINIStr "$PLUGINSDIR\${IOS}" "Field 6" "State" "0"
WriteINIStr "$PLUGINSDIR\${IOS}" "Field 6" "Text" "下载更多精品软件,访问迅雷网站(&D)"
WriteINIStr "$PLUGINSDIR\${IOS}" "Field 6" "Left" "120"
WriteINIStr "$PLUGINSDIR\${IOS}" "Field 6" "Right" "315"
WriteINIStr "$PLUGINSDIR\${IOS}" "Field 6" "Top" "129"
WriteINIStr "$PLUGINSDIR\${IOS}" "Field 6" "Bottom" "140"
FunctionEnd
Function   FinishPageShow
   ReadINIStr $0 "$PLUGINSDIR\${IOS}" "Field 6" "HWND"
   SetCtlColors $0 0x000000 0xFFFFFF
FunctionEnd
Function  FinishPageLeave
ReadINIStr $0 "$PLUGINSDIR\${IOS}" "Field 6" "State"
StrCmp $0 "1" +1 +2
ExecShell open "http://www.xunlei.com"
FunctionEnd
Function .onInstSuccess
  HideWindow
  Exec '"$INSTDIR\Program\SetupHelper.exe" /register_plugins'
  Exec '"$INSTDIR\Program\SetupHelper.exe" /open_firewall'
  Exec '"$INSTDIR\Program\SetupHelper.exe" /for_all_users'
  ExecWait '"$INSTDIR\Program\Thunder5.exe" /installaddin:{76F61D18-C813-432E-BC7A-A41A45D04113}|迅雷安全下载组件|..\Components\security\ThunderSafe.dll'
Sleep 500
  ReadIniStr $6 "$INI" "Field 6" "state"
  ${If} $6 == 1
   ExecWait '"$INSTDIR\Program\Thunder5.exe" /Installaddin:{EBDF4650-539A-4CC5-B6F2-B7C5E5D59735}|迅雷看看|..\Plugins\KanKanTop\KanKanTop.dll'
  ${EndIf}
Sleep 500
ReadIniStr $5 "$INI" "Field 5" "state"
  ${If} $5 == 1
    ExecWait '"$INSTDIR\Program\Thunder5.exe" /Installaddin:{1FC7CAC6-2DA8-4cb0-B440-C069956CC0CA}|狗狗搜索排行|..\Plugins\GouGouTop\GouGouTop.dll'
  ${EndIf}
FunctionEnd
关键词:NSIS

赞助商链接: