脚本:XP补丁打包

优质
小牛编辑
141浏览
2023-12-01
首先要说的,这个仅属把补丁打包而安装补丁的过程是通过运行XPLODE.EXE而实现的!

本脚本主要实现可以在安装过程调用Xplode实现马上安装的,另外可以选择重启后安装,就是写入注册实现重启后运行一次的命令!我将补丁放在SEV里面 ,SE2为另外的一些软件也可以。CLEAN.EXE为垃圾清理工具。

目录参考

├─SEV
│ └─SE2
└─TEMP
└─ XPLODEREGISTRY.X4E
└─XPLODEFILEOPS.X4E
└─XPLODEEXECUTE.X4E
└─XPLODE.XML
└─XPLODE.X4D
└─XPLODE.EXE
└─CLEAN.EXE

定义常量的示例:

; 该脚本使用 HM VNISEdit 脚本编辑器向导产生

; 安装程序初始定义常量
!define PRODUCT_NAME "Xp补丁包"
!define /date PRODUCT_VERSION "%y%m%d"
!define PRODUCT_PUBLISHER "似水年华"
!define PRODUCT_WEB_SITE "http://www.Dreams8.com"
SetCompressor /SOLID lzma

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


; MUI 预定义常量
!define MUI_ABORTWARNING
!define MUI_ICON "TEMP\warningshield.ico"

; 欢迎页面
!define MUI_WELCOMEFINISHPAGE_BITMAP "temp\dreams8.bmp"
!insertmacro MUI_PAGE_WELCOME
; 许可协议页面
!define MUI_LICENSEPAGE_RADIOBUTTONS
!insertmacro MUI_PAGE_LICENSE "TEMP\Licence.txt"
; 组件选择页面
!insertmacro MUI_PAGE_COMPONENTS
; 安装过程页面
!insertmacro MUI_PAGE_INSTFILES
; 安装完成页面
!insertmacro MUI_PAGE_FINISH

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

; 安装预释放文件
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

;安装界面下画线的文字
BrandingText "Http://www.Dreams8.com 似水年华"

;声明版权
VIProductVersion "2006.04.09.0"
VIAddVersionKey /LANG=2052 "ProductName" "Xp 批量安装补丁包"
VIAddVersionKey /LANG=2052 "CompanyName" "WwW.Dreams8.CoM"
VIAddVersionKey /LANG=2052 "LegalTrademarks" "似水年华"
VIAddVersionKey /LANG=2052 "LegalCopyright" "(C) 2006 Dreams8.Com"
VIAddVersionKey /LANG=2052 "FileDescription" "Xp 补丁包"
VIAddVersionKey /LANG=2052 "FileVersion" "${PRODUCT_VERSION}"
VIAddVersionKey /LANG=2052 "梦想吧" "Www.Dreams8.Com"

; ------ MUI 现代界面定义结束 ------


Name "${PRODUCT_NAME}${PRODUCT_VERSION}"
Caption "Xp补丁离线批量安装包 ${PRODUCT_VERSION} By似水年华"
OutFile "SEV.exe"
InstallDir "$WINDIR\SVCPACK"
ShowInstDetails nevershow

SectionGroup /e "Xp补丁包"
  Section "!补丁包" SEC01
  SectionIn RO
  SetOutPath "$INSTDIR\SEV"
  SetOverwrite ifnewer
  File /r "SEV\*.*"
  SetOutPath "$INSTDIR"
  File "XPLODEREGISTRY.X4E"
  File "XPLODEFILEOPS.X4E"
  File "XPLODEEXECUTE.X4E"
  File "XPLODE.XML"
  File "XPLODE.X4D"
  File "XPLODE.EXE"
  File "CLEAN.EXE"
SectionEnd

Section /o "立即开始安装补丁" g1o1
ExecWait "$INSTDIR\XPLODE.EXE"
SectionEnd

Section "下次重启安装补丁" g1o2
WriteRegStr "HKLM" "SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" "Expand String Value" "$INSTDIR\XPLODE.EXE"
SectionEnd
SectionGroupEnd

#-- 根据 NSIS 脚本编辑规则,所有 Function 区段必须放置在 Section 区段之后编写,以避免安装程序出现未可预知的问题。--#
Function .onInit
  StrCpy $1 ${g1o1} ; Group 1 - Option 1 is selected by default
  GetDllVersion "$SYSDIR\user32.dll" $R0 $R1
  IntOp $R2 $R0 / 0x00010000
  IntOp $R3 $R0 0x0000FFFF
  IntOp $R4 $R1 / 0x00010000
  IntOp $R5 $R1 0x0000FFFF
  StrCpy $0 "$R2$R3"
  IntCmp $0 51 +3 +1 +1
     MessageBox MB_OK|MB_ICONEXCLAMATION "本程序仅能运行于 Windows XP 操作系统!" /SD IDOK
     Quit
FunctionEnd

Function .onSelChange
  !insertmacro StartRadioButtons $1
    !insertmacro RadioButton ${g1o1}
    !insertmacro RadioButton ${g1o2}
  !insertmacro EndRadioButtons
FunctionEnd

Function .onMouseOverSection
!insertmacro MUI_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "Xp补丁离线批量安装包"
  !insertmacro MUI_DESCRIPTION_TEXT ${g1o1} "立即开始安装补丁,建议重启以便解压后的垃圾全部清理!"
  !insertmacro MUI_DESCRIPTION_TEXT ${g1o2} "系统重启后安装补丁"
!insertmacro MUI_DESCRIPTION_END
FunctionEnd

!define IDC_ABOUT    1300
!define IDC_LINK    1301
!define IDM_ABOUT    1

Function .onPageCallback
    ${If} $MSG = ${WM_INITDIALOG}
        Push $0
        Push $1
        Push $2
        Push $3
        ${GetDlgItemRect} $0 $1 $2 $3 $HWNDPARENT ${IDC_CANCEL}
        IntOp $0 $2 - $0
        IntOp $2 $3 - $1
        ${CreateButton} "关于(A)" 20 $1 $0 $2 $HWNDPARENT ${IDC_ABOUT}
        IntOp $3 $0 + 30
        IntOp $1 $1 + 3
        IntOp $2 $2 - 2
        ${CreateLink} $3 $1 90 $2 $HWNDPARENT ${IDC_LINK}
        ${GetSystemMenu} $0 $HWNDPARENT
        ${AppendMenu} $0 ${MF_SEPARATOR} 0 0
        ${AppendMenu} $0 ${MF_STRING} ${IDM_ABOUT} "关于安装程序(A)"
        Pop $3
        Pop $2
        Pop $1
        Pop $0
    ${ElseIf} $MSG = ${WM_COMMAND}
        ${If} $WPARAM = ${IDC_ABOUT}
            ${MessageBox2} `==================$\n\
                            ===Windows Xp sp2 补丁安装包===$\n\
                            感谢你使用这个补丁离线安装包,希望能$\n\
                            给您带来方便.同时也欢迎您常来梦想吧$\n\
                            WWW.DREAMS8.COM逛逛,似水年华在此 $\n\
                            谢谢各位的支持,我相信我们会做得更好!$\n$\n
                            梦想吧|似水年华2006年4月9日` `关于 $(^NameDA)` ${MB_OK}|${MB_ICONINFORMATION}
        ${ElseIf} $WPARAM = ${IDC_LINK}
            ExecShell open `http://www.dreams8.com/`
        ${EndIf}
    ${ElseIf} $MSG = ${WM_DRAWITEM}
        ${DrawLink} `访问梦想吧` ${IDC_LINK} $LPARAM
    ${ElseIf} $MSG = ${WM_SYSCOMMAND}
        ${If} $WPARAM = ${IDM_ABOUT}
            ${MessageBox2} `梦想吧|Dreams8 WWW.DREAMS8.COM$\n版权所有 (C) 2006 似水年华$\n$\n梦想吧主页:$\nhttp://www.dreams8.com/` `关于安装程序` ${MB_OK}|${MB_ICONINFORMATION}
        ${EndIf}
    ${EndIf}
FunctionEnd