有爱,有技术,有你^_^)y
╱人◕‿‿◕人╲订下契约(注册新用户)

合作站点账号登陆

QQ登录

只需一步,快速开始

快捷导航
查看: 2038|回复: 1
收起左侧

[普通教程] nsis制作安装包脚本代码发出

[复制链接]

该用户从未签到

3

主题

1

好友

1649

积分

Continue

积分
1649
发表于 2012-5-1 11:29:11 | 显示全部楼层 |阅读模式

╱人◕‿‿◕人╲定下契约

您需要 登录 才可以下载或查看,没有账号?╱人◕‿‿◕人╲订下契约(注册新用户)

x
本帖最后由 Croual回忆 于 2012-5-1 11:31 编辑

这个脚本基于我对新主题的封装曾用。现在放出代码= =也方便我以后忘记了什么的。。。

ps:此脚本其他萌化组成员可以直接调用,只需修改某些参数(当然我不见得比别人做的好),献丑了


效果:有闪图,有语言选择,有循环播放音乐。还有更多的细节乃们自己体会吧= = 我只用了安装自带的插件,其他插件的功能乃们自己有兴趣自己研究吧,毕竟脚本语言偶很少用,太简单,没有太多深入研究的兴趣= =|||

; 安装程序初始定义常量
!define PRODUCT_NAME "夏空カナタ[win7主题]★回忆制作★"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "Corual★回忆★"
!define PRODUCT_WEB_SITE "http://blog.sina.com.cn/kamisa32"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

SetCompressor lzma

; ------ MUI 现代界面定义 (1.67 版本以上兼容) ------
!include "MUI.nsh"

; MUI 预定义常量
!define MUI_ABORTWARNING
!define MUI_WELCOMEFINISHPAGE_BITMAP "E:\welcome.bmp"
!define MUI_ICON "忆云logo.ico"
!define MUI_UNICON "忆云logo.ico"
!define MUI_WELCOMEPAGE_TITLE "\r\n 夏空カナタ[win7主题]安装向导"
!define MUI_PAGE_HEADER_TEXT " 许可协议"
!define MUI_PAGE_HEADER_SUBTEXT "   继续前阅读下列最要信息"
!define MUI_FINISHPAGE_TITLE "\r\n 已完成夏空カナタ[win7主题]的安装"
!define MUI_WELCOMEPAGE_TEXT "  忆云萌化组不会在任何作品中捆绑任何有害程序,\n\n请大家放心使用!此萌化主题安装不会引起系统重启,\r\n\r\n使用前请打好樱茶的补丁!\r\n\r\n  主题作者:Corual.回忆\r\n\r\n  官方网址:革月年华\r\n\r\n  $_CLICK"
!define MUI_LICENSEPAGE_TEXT_TOP "   请仔细阅读下列许可协议。在你继续安装之前必须同意这些条款才能继续安装。   "
!define MUI_DIRECTORYPAGE_TEXT_TOP "   现在将“夏空カナタ[win7]主题”安装到下列文件夹中,如果你想刚改目录,请按“浏览” $_CLICK"


; 语言选择窗口常量设置
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"



; 欢迎页面

!insertmacro MUI_PAGE_WELCOME

; 许可协议页面

!insertmacro MUI_PAGE_LICENSE "使用声明(忆云).txt"

; 安装目录选择页面
!define MUI_PAGE_HEADER_TEXT " 选择目标位置"
!define MUI_PAGE_HEADER_SUBTEXT "   你想将“夏空カナタ[win7]主题”安装在什么地方"
!insertmacro MUI_PAGE_DIRECTORY
; 安装过程页面
!insertmacro MUI_PAGE_INSTFILES
; 安装完成页面
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\Summer empty the other side.theme"
!define MUI_FINISHPAGE_SHOWREADME_TEXT "运行夏空カナタ[win7主题]"

!insertmacro MUI_PAGE_FINISH

; 安装卸载过程页面
!define MUI_PAGE_HEADER_TEXT " 正在执行"
!insertmacro MUI_UNPAGE_INSTFILES

; 安装界面包含的语言设置
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Japanese"
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_LANGUAGE "TradChinese"


; 安装预释放文件
!insertmacro MUI_RESERVEFILE_LANGDLL
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; ------ MUI 现代界面定义结束 ------

ReserveFile "${NSISDIR}\Plugins\advsplash.dll"
ReserveFile "图签.bmp"

ReserveFile "${NSISDIR}\Plugins\system.dll"
ReserveFile "hope - 海猫鸣泣之时.mp3"

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "test.exe"
InstallDir "C:\Windows\Resources\Themes"
ShowInstDetails show
ShowUnInstDetails show
BrandingText "忆云萌化组 Corual's theme"

Section "MainSection" SEC01
  SetOutPath "$INSTDIR\Summer empty the other side\cur"
  SetOverwrite ifnewer
File "installdir\Summer empty the other side\cur\alternate.cur"
  File "installdir\Summer empty the other side\cur\busy.ani"
  File "installdir\Summer empty the other side\cur\diagonal1.ani"
  File "installdir\Summer empty the other side\cur\diagonal2.ani"
File "installdir\Summer empty the other side\cur\handwriting.cur"
  File "installdir\Summer empty the other side\cur\help.ani"
  File "installdir\Summer empty the other side\cur\horizontal.ani"
  File "installdir\Summer empty the other side\cur\K.inf"
  File "installdir\Summer empty the other side\cur\link.ani"
  File "installdir\Summer empty the other side\cur\move.ani"
  File "installdir\Summer empty the other side\cur\normal.cur"
  File "installdir\Summer empty the other side\cur\precision.ani"
  File "installdir\Summer empty the other side\cur\text.ani"
  File "installdir\Summer empty the other side\cur\unavailable.cur"
  File "installdir\Summer empty the other side\cur\vertical.ani"
  File "installdir\Summer empty the other side\cur\working.ani"
  SetOutPath "$INSTDIR\Summer empty the other side\icon"
  File "installdir\Summer empty the other side\icon\empty_reccyle_bin.ico"
  File "installdir\Summer empty the other side\icon\full_reccyle_bin.ico"
  File "installdir\Summer empty the other side\icon\my_computer.ico"
  File "installdir\Summer empty the other side\icon\my_documents.ico"
  File "installdir\Summer empty the other side\icon\network.ico"
  SetOutPath "$INSTDIR\Summer empty the other side\Shell\NormalColor"
  File "installdir\Summer empty the other side\Shell\NormalColor\shellstyle.dll"
  SetOutPath "$INSTDIR\Summer empty the other side\Shell\NormalColor\zh-CN"
  File "installdir\Summer empty the other side\Shell\NormalColor\zh-CN\shellstyle.dll.mui"
  SetOutPath "$INSTDIR\Summer empty the other side"
  File "installdir\Summer empty the other side\Summer empty the other side.msstyles"
  File "installdir\Summer empty the other side\Summer empty the other side.theme"
  SetOutPath "$INSTDIR\Summer empty the other side\wallpaper"
  File "installdir\Summer empty the other side\wallpaper\wallpaper1.jpg"
  SetOutPath "$INSTDIR\Summer empty the other side\zh-CN"
  File "installdir\Summer empty the other side\zh-CN\aero.msstyles.mui"
  SetOutPath "$INSTDIR"
  File "installdir\Summer empty the other side.theme"
SectionEnd

Section -AdditionalIcons

  CreateDirectory "$SMPROGRAMS\夏空カナタ[win7主题]"
  CreateShortCut "$SMPROGRAMS\夏空カナタ[win7主题]\Uninstall.lnk" "$INSTDIR\uninst.exe"


SectionEnd

Section -Post
  WriteUninstaller "$INSTDIR\uninst.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}" "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

#-- 根据 NSIS 脚本编辑规则,所有 Function 区段必须放置在 Section 区段之后编写,以避免安装程序出现未可预知的问题。--#


outfile test.exe
Function .onInit
  InitPluginsDir
!insertmacro MUI_LANGDLL_DISPLAY
  File "/oname=$PLUGINSDIR\bgm_hope_-_海猫鸣泣之时.mp3" "hope - 海猫鸣泣之时.mp3"
  ; 打开音乐文件
System::Call "winmm.dll::mciSendString(t 'OPEN $PLUGINSDIR\bgm_hope_-_海猫鸣泣之时.mp3 TYPE MPEGVIDEO ALIAS BGMUSIC', t .r0, i 130, i 0)"
  ; 开始播放音乐文件
  System::Call "winmm.dll::mciSendString(t 'PLAY BGMUSIC NOTIFY REPEAT', t .r0, i 130, i 0)"
  File "/oname=$PLUGINSDIR\Splash_图签.bmp" "图签.bmp"
  ; 使用闪屏插件显示闪屏
  advsplash::show 3000 1800 1200 -1 "$PLUGINSDIR\Splash_图签"
  Pop $0 ; $0 返回 '1' 表示用户提前关闭闪屏, 返回 '0' 表示闪屏正常结束, 返回 '-1' 表示闪屏显示出错


FunctionEnd

Function .onGUIEnd
  ; 停止播放音乐文件
  System::Call "winmm.dll::mciSendString(t 'STOP BGMUSIC',t .r0,i 130,i 0)"
  ; 关闭音乐文件
System::Call "winmm.dll::mciSendString(t 'CLOSE BGMUSIC',t .r0,i 130,i 0)"
FunctionEnd






/******************************
*  以下是安装程序的卸载部分  *
******************************/

Section Uninstall
  Delete "$INSTDIR \${PRODUCT_NAME}.url"
  Delete "$INSTDIR \uninst.exe"
  Delete "$INSTDIR \满是忧郁回忆_新浪博客.url"
  Delete "$INSTDIR \Summer empty the other side.theme"
  Delete "$INSTDIR \Summer empty the other side\zh-CN\aero.msstyles.mui"
  Delete "$INSTDIR \Summer empty the other side\wav\usb_out.wav"
  Delete "$INSTDIR \Summer empty the other side\wav\usb_in.wav"
  Delete "$INSTDIR \Summer empty the other side\wav\usb_fail.wav"
  Delete "$INSTDIR \Summer empty the other side\wav\theme_change.wav"
  Delete "$INSTDIR \Summer empty the other side\wav\system_exit.wav"
  Delete "$INSTDIR \Summer empty the other side\wav\logoff.wav"
  Delete "$INSTDIR \Summer empty the other side\wav\login.wav"
  Delete "$INSTDIR \Summer empty the other side\wav\error.wav"
  Delete "$INSTDIR \Summer empty the other side\wav\empty_bin.wav"
  Delete "$INSTDIR \Summer empty the other side\wav\click.wav"
  Delete "$INSTDIR \Summer empty the other side\wav\battery_verylow.wav"
  Delete "$INSTDIR \Summer empty the other side\wav\battery_low.wav"
  Delete "$INSTDIR \Summer empty the other side\wallpaper\wallpaper1.jpg"
  Delete "$INSTDIR \Summer empty the other side\Summer empty the other side.theme"
  Delete "$INSTDIR \Summer empty the other side\Summer empty the other side.msstyles"
  Delete "$INSTDIR \Summer empty the other side\Shell\NormalColor\zh-CN\shellstyle.dll.mui"
  Delete "$INSTDIR \Summer empty the other side\Shell\NormalColor\shellstyle.dll"
  Delete "$INSTDIR \Summer empty the other side\icon\network.ico"
  Delete "$INSTDIR \Summer empty the other side\icon\my_documents.ico"
  Delete "$INSTDIR \Summer empty the other side\icon\my_computer.ico"
  Delete "$INSTDIR \Summer empty the other side\icon\full_reccyle_bin.ico"
  Delete "$INSTDIR \Summer empty the other side\icon\empty_reccyle_bin.ico"
  Delete "$INSTDIR \Summer empty the other side\cur\working.ani"
  Delete "$INSTDIR R\Summer empty the other side\cur\vertical.ani"
  Delete "$INSTDIR \Summer empty the other side\cur\unavailable.cur"
  Delete "$INSTDIR \Summer empty the other side\cur\text.ani"
  Delete "$INSTDIR \Summer empty the other side\cur\precision.ani"
  Delete "$INSTDIR \Summer empty the other side\cur\normal.cur"
  Delete "$INSTDIR \Summer empty the other side\cur\move.ani"
  Delete "$INSTDIR \Summer empty the other side\cur\link.ani"
  Delete "$INSTDIR \Summer empty the other side\cur\K.inf"
  Delete "$INSTDIR \Summer empty the other side\cur\horizontal.ani"
  Delete "$INSTDIR \Summer empty the other side\cur\help.ani"
  Delete "$INSTDIR \Summer empty the other side\cur\handwriting.cur"
  Delete "$INSTDIR \Summer empty the other side\cur\diagonal2.ani"
  Delete "$INSTDIR \Summer empty the other side\cur\diagonal1.ani"
  Delete "$INSTDIR \Summer empty the other side\cur\busy.ani"
  Delete "$INSTDIR \Summer empty the other side\cur\alternate.cur"

  Delete  "$SMPROGRAMS \夏空カナタ[win7主题]★回忆制作★\Uninstall.lnk"
  Delete  "$SMPROGRAMS \夏空カナタ[win7主题]★回忆制作★\Website.lnk"
  Delete "$DESKTOP\Corual.lnk"

  RMDir "$SMPROGRAMS \夏空カナタ[win7主题]★回忆制作★"
  RMDir "$INSTDIR \Summer empty the other side\zh-CN"
  RMDir "$INSTDIR \Summer empty the other side\wav"
RMDir "$INSTDIR \Summer empty the other side\wallpaper"
  RMDir "$INSTDIR \Summer empty the other side\Shell\NormalColor\zh-CN"
  RMDir "$INSTDIR \Summer empty the other side\Shell\NormalColor"
  RMDir "$INSTDIR \Summer empty the other side\icon"
  RMDir "$INSTDIR \Summer empty the other side\cur"
  RMDir "$INSTDIR \Summer empty the other side"

  RMDir "$INSTDIR "

  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  SetAutoClose true
SectionEnd

#-- 根据 NSIS 脚本编辑规则,所有 Function 区段必须放置在 Section 区段之后编写,以避免安装程序出现未可预知的问题。--#

Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "您确实要完全移除 $(^Name) ,及其所有的组件?" IDYES +2
  Abort
FunctionEnd

Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从您的计算机移除。"
FunctionEnd


评分

参与人数 1宅币 +10 贡献 +1 收起 理由
氺菓 + 10 + 1 o(* ̄▽ ̄*)ブ 发糖

查看全部评分

签名被小宅喵吞掉了~~~~(>_<)~~~~
回复

使用道具 举报

签到天数: 1 天

连续签到: 1 天

[LV.1]初来乍到

396

主题

307

好友

5万

积分

第三章

听着时间涓滴败血

积分
51214
发表于 2012-5-1 22:00:37 | 显示全部楼层
我还真是不太了解这...
签名被小宅喵吞掉了~~~~(>_<)~~~~
回复 支持 反对

使用道具 举报

本版积分规则

小黑屋|技术宅(基宅) ( 粤ICP备18082987号-1 | 浙公网安备 33010902001746号 )

GMT+8, 2024-5-21 10:41 , Processed in 1.084268 second(s), 20 queries , Redis On.

Copyright © 2018 技术宅社区

Powered by Discuz! X3.5

快速回复 返回顶部 返回列表