脚本:微软官方主题

优质
小牛编辑
135浏览
2023-12-01
引用脚本的内容:


; 该脚本使用 HM VNISEdit 脚本编辑器向导产生
; 脚本编译:非正常注册
!include "LogicLib.nsh"
; 安装程序初始定义常量
!define PRODUCT_NAME "微软官方主题"
!define PRODUCT_VERSION "年韵2006"
!define PRODUCT_PUBLISHER "Microsoft"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"
SetCompressor lzma
InstType "完全安装"
; ------ MUI 现代界面定义 (1.67 版本以上兼容) ------
!include "MUI.nsh"
; MUI 预定义常量
!define MUI_ABORTWARNING
!define MUI_ICON "0.ico"
!define MUI_UNICON "3.ico"
!define MUI_WELCOMEFINISHPAGE_BITMAP "1.bmp"
; 语言选择窗口常量设置
!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_COMPONENTS
; 安装目录选择页面
!insertmacro MUI_PAGE_DIRECTORY
; 开始菜单设置页面
var ICONS_GROUP
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "微软增值软件"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
; 安装过程页面
!insertmacro MUI_PAGE_INSTFILES
; 安装完成页面
!define MUI_FINISHPAGE_SHOWREADME "readme.txt"
!insertmacro MUI_PAGE_FINISH
; 安装卸载过程页面
!insertmacro MUI_UNPAGE_INSTFILES
; 安装界面包含的语言设置
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_LANGUAGE "TradChinese"
; 安装预释放文件
!insertmacro MUI_RESERVEFILE_LANGDLL
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; ------ MUI 现代界面定义结束 ------
ReserveFile "${NSISDIR}\Plugins\advsplash.dll"
ReserveFile "OEMLOGO.bmp"
ReserveFile "Open.wav"
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "主题包.EXE"
InstallDir "$PROGRAMFILES\CNP2006"
ShowInstDetails show
ShowUnInstDetails show
BrandingText "失去记忆的风 QQ:82695161 特别制作,谢谢您的支持!"
; 激活安装日志记录,该日志文件将会作为卸载文件的依据(注意,本区段必须放置在所有区段之前)

SectionGroup "微软正版增值软件" SecInterfaces
Section "年韵 2006" SEC01
  SectionIn 1
  SetOutPath "$RESOURCES\Themes"
  SetOverwrite on
  File /r "Themes\*.*"
  SetOutPath "$RESOURCES\Themes\Resources"
  File /r "Themes\Resources\*.*"
  SetOutPath "$RESOURCES\Themes\Luna\Shell\NormalColor"
  File /r "Themes\Shell\NormalColor\*.*"
  SetOutPath "$WINDIR\Web\Wallpaper"
  File "Themes\Shell\Wallpaper\*.*"
  SetOutPath "$WINDIR\Cursors"
  File /r "Themes\Cursors\*.*"
  SetOutPath "$WINDIR\Media"
  File /r "Themes\Media\*.*"
  SetOutPath "$PROGRAMFILES\CNP2006"
  File /r "Themes\1\*.*"
  
SectionEnd
Section " Date_Time" SEC02
  SectionIn 1
  SetOutPath "$PROGRAMFILES\Chinese Date_Time"
  SetOverwrite ifnewer
  File /r "Chinese Date_Time\*.*"
; 创建开始菜单快捷方式
  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
  CreateDirectory "$SMPROGRAMS\微软增值软件\日历时钟"
  CreateShortCut "$SMPROGRAMS\微软增值软件\日历时钟\ICalClk.lnk" "$PROGRAMFILES\Chinese Date_Time\ICalClk.exe"
  !insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
Section -AdditionalIcons
  SetOutPath $INSTDIR
  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
  CreateDirectory "$SMPROGRAMS\微软增值软件"
  CreateShortCut "$SMPROGRAMS\微软增值软件\卸载日历时钟.lnk" "$INSTDIR\uninst.exe"
  !insertmacro MUI_STARTMENU_WRITE_END
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}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
#-- 根据 NSIS 脚本编辑规则,所有 Function 区段必须放置在 Section 区段之后编写,以避免安装程序出现未可预知的问题。--#
; 区段组件描述
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "微软官方2006主题."
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC02} "日历(包括农历和公历)与世界时钟,绿色,可直接删除。"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Function .onInit
  InitPluginsDir
  File "/oname=$PLUGINSDIR\Splash_OEMLOGO.bmp" "OEMLOGO.bmp"
  File "/oname=$PLUGINSDIR\Splash_Open.wav" "Open.wav"
  ; 使用闪屏插件显示闪屏
  advsplash::show 1000 500 500 -1 "$PLUGINSDIR\Splash_OEMLOGO"
  Pop $0 ; $0 返回 '1' 表示用户提前关闭闪屏, 返回 '0' 表示闪屏正常结束, 返回 '-1' 表示闪屏显示出错
  !insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
SectionGroupEnd
/******************************
*  以下是安装程序的卸载部分  *
******************************/
; 根据安装日志卸载文件的调用宏
!macro DelFileByLog LogFile
  ifFileExists `${LogFile}` 0 +4
    Push `${LogFile}`
    Call un.DelFileByLog
    Delete `${LogFile}`
!macroend
Section Uninstall
  !insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP
  ; 调用宏只根据安装日志卸载安装程序自己安装过的文件
  !insertmacro DelFileByLog "$INSTDIR\install.log"
  ; 清除安装程序创建的且在卸载时可能为空的子目录,对于递归添加的文件目录,请由最内层的子目录开始清除(注意,不要带 /r 参数,否则会失去 DelFileByLog 的意义)
  RMDir /r "$PROGRAMFILES\CNP2006"
  RMDir /r "$PROGRAMFILES\Chinese Date_Time"
  RMDir "$WINDIR\Web\Wallpaper"
  RMDir "$WINDIR\Media"
  RMDir "$WINDIR\Cursors"
  RMDir "$SMPROGRAMS\$ICONS_GROUP"
  RMDir "$RESOURCES\Themes"
  RMDir ""
  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 "你确实要完全移除 微软日历时钟,及其所有的组件?" IDYES +2
  Abort
FunctionEnd
Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "微软日历时钟 已成功地从你的计算机移除。"
FunctionEnd
; 以下是卸载程序通过安装日志卸载文件的专用函数,请不要随意修改
Function un.DelFileByLog
  Exch $R0
  Push $R1
  Push $R2
  Push $R3
  FileOpen $R0 $R0 r
  ${Do}
    FileRead $R0 $R1
    ${IfThen} $R1 == `` ${|} ${ExitDo} ${|}
    StrCpy $R1 $R1 -2
    StrCpy $R2 $R1 11
    StrCpy $R3 $R1 20
    ${If} $R2 == "File: wrote"
    ${OrIf} $R2 == "File: skipp"
    ${OrIf} $R3 == "CreateShortCut: out:"
    ${OrIf} $R3 == "created uninstaller:"
      Push $R1
      Push `"`
      Call un.DelFileByLog.StrLoc
      Pop $R2
      ${If} $R2 != ""
        IntOp $R2 $R2 + 1
        StrCpy $R3 $R1 "" $R2
        Push $R3
        Push `"`
        Call un.DelFileByLog.StrLoc
        Pop $R2
        ${If} $R2 != ""
          StrCpy $R3 $R3 $R2
          Delete /REBOOTOK $R3
        ${EndIf}
      ${EndIf}
    ${EndIf}
    StrCpy $R2 $R1 7
    ${If} $R2 == "Rename:"
      Push $R1
      Push "->"
      Call un.DelFileByLog.StrLoc
      Pop $R2
      ${If} $R2 != ""
        IntOp $R2 $R2 + 2
        StrCpy $R3 $R1 "" $R2
        Delete /REBOOTOK $R3
      ${EndIf}
    ${EndIf}
  ${Loop}
  FileClose $R0
  Pop $R3
  Pop $R2
  Pop $R1
  Pop $R0
FunctionEnd
Function un.DelFileByLog.StrLoc
  Exch $R0
  Exch
  Exch $R1
  Push $R2
  Push $R3
  Push $R4
  Push $R5
  StrLen $R2 $R0
  StrLen $R3 $R1
  StrCpy $R4 0
  ${Do}
    StrCpy $R5 $R1 $R2 $R4
    ${If} $R5 == $R0
    ${OrIf} $R4 = $R3
      ${ExitDo}
    ${EndIf}
    IntOp $R4 $R4 + 1
  ${Loop}
  ${If} $R4 = $R3
    StrCpy $R0 ""
  ${Else}
    StrCpy $R0 $R4
  ${EndIf}
  Pop $R5
  Pop $R4
  Pop $R3
  Pop $R2
  Pop $R1
  Exch $R0
FunctionEnd