脚本:极点五笔4.2版

优质
小牛编辑
115浏览
2023-12-01
极点4.2版安装程序的NSIS脚本文件。使用方法:
①下载极点4.2版并安装到c:\freewb目录,之后将此脚本文件解压至c:\freewb目录中
②下载并安装NSIS程序
③根据自己的需要编辑此脚本并编译即可。

引用 freewb.nsi 的内容:

; Generated NSIS script file (generated by makensitemplate.phtml 0.21)
; by 209.219.38.215 on Feb 08 03 @ 19:03

; NOTE: this .NSI script is designed for NSIS v1.8+
!include "caps.nsh"
SetCompressor LZMA
Name "极点五笔4.2版"
OutFile "freewb42.exe"
AutoCloseWindow true
;Icon "setup.ico"
SetFont "宋体" 9
ShowInstDetails show
CRCCheck off

Caption "极点五笔安装程序"
SubCaption 0 " "
SubCaption 1 " "
SubCaption 2 " "
SubCaption 3 " "
SubCaption 4 " "
BrandingText /TRIMLEFT "程序开发:杜志民"

Function .onInit
  ReadRegStr $INSTDIR HKLM "SOFTWARE\极点中文" "系统目录"
  StrCmp "" $INSTDIR nDefault Over
nDefault:
  StrCpy $INSTDIR "$PROGRAMFILES\freewb"
Over:
FunctionEnd

LicenseText "极点五笔使用授权协议$\r$\n版本:4.2版" "下一步"
LicenseBkColor fdfdfd
LicenseForceSelection checkbox "我已阅读并接受此授权协议"
LicenseData "license.txt"

DirText "$\r$\n欢迎使用极点五笔4.2版"

; Pages
Page license
Page directory
Page instfiles

;InstallColors 000000 fdfdfd
InstProgressFlags smooth colored

InstallDir $INSTDIR

Section "WriteReg"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\极点中文" "系统目录" "$INSTDIR"
SectionEnd

#创建快捷方式段
Section "Shortcuts"
  SetOutPath $INSTDIR
  CreateDirectory $SMPROGRAMS\极点中文
  CreateShortCut "$SMPROGRAMS\极点中文\极点目录.lnk" "$INSTDIR" ""
  CreateShortCut "$SMPROGRAMS\极点中文\使用说明.lnk" "$INSTDIR\freewb.chm" ""
  CreateShortCut "$SMPROGRAMS\极点中文\卸载极点.lnk" "$INSTDIR\unregistry.exe" ""
SectionEnd

;================================================================================
#默认安装段
Section "" ; (default section)
CreateDirectory "$INSTDIR\skin"
CreateDirectory "$INSTDIR\mb"
CreateDirectory "$INSTDIR\mb\default"
CreateDirectory "$INSTDIR\background"

;拷贝背景图版
SetOutPath "$INSTDIR\background"
SetOverwrite off
File "background\leaf.bmp"
File "background\gray_fade.bmp"

;拷贝码表文件
SetOutPath "$INSTDIR\mb\default"
fILE "mb\default\freewb.dat"
File "mb\default\freewb.mb"
File "mb\default\freewbcht.mb"
File "mb\default\quick.mb"
File "mb\default\user.ini"
File "mb\default\attach.mb"

;拷贝系统文件
SetOutPath "$INSTDIR"
SetOverwrite on
File "convert.mb"
File "freewb.bin"
File "freewb.bex"
File "freewb.chm"
File "freewb.dll"
File "freewb.ime"
File "unInstallIME.exe"

SetOverwrite off
File "freewb.ini"
SetOverwrite on
File "g2b.dat"
File "registry.exe"

;拷贝皮肤文件
SetOutPath "$INSTDIR\skin"
SetOverwrite off
File "skin\fox.ini"
File "skin\fox.bmp"

File "skin\paper.ini"
File "skin\paper.bmp"

WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\极点中文" "DisplayName" "卸载极点五笔"
;WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\极点中文" "UninstallString" '"$INSTDIR\registry.exe" /u'
WriteUninstaller "$INSTDIR\unregistry.exe"

	IfSilent mSilent
  ExecWait '$INSTDIR\registry.exe /p'
  goto Over
mSilent:
  ExecWait '$INSTDIR\registry.exe /s '
Over:
SectionEnd

;================================================================================
#卸载程序段
;================================================================================
UninstallText "本程序将卸载极点五笔" "系统安装路径:"
UninstallCaption "极点五笔"
UninstallSubCaption 0 " "
UninstallSubCaption 1 " "
UninstallSubCaption 2 " "
UninstallButtonText "卸载"
ShowUninstDetails show

Section Uninstall
  ;System::Call 'kernel32::CreateMutexA(i 0, i 0, t "mutex_freeime") i .r1 ?e'
  ;Pop $R0
  ;IntCmp $R0 0 +6
	;System::Call 'kernel32::CloseMutexA($R0) i .r1 ?e'
  ;WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" "freewb_1" '"$INSTDIR\registry.exe" /u /s'
  ;WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" "freewb_2" '"$INSTDIR\unregistry.exe" /S'
  ;MessageBox MB_OK|MB_ICONINFORMATION  "极点五笔正在使用,下次重启时将自动完成卸载。$\r$\n"
  ;goto Over

  execwait '"$INSTDIR\registry.exe" /u /p /s' $0
	IntCmp $0 100 Over

	Rmdir  /r "$SMPROGRAMS\极点中文"
	DeleteRegValue  HKEY_LOCAL_MACHINE "SOFTWARE\极点中文" "系统目录"
	DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\极点中文"
	;===========================================================================
	#delete the skin section
	RmDir /r "$INSTDIR\skin"
	
	;卸载背景
	RmDir /r "$INSTDIR\background"
	
	;码表文件
	Delete "$INSTDIR\mb\default\freewb.dat"
	Delete "$INSTDIR\mb\default\freewb.mb"
	Delete "$INSTDIR\mb\default\freewbcht.mb"
	Delete "$INSTDIR\mb\default\user.ini"
	Delete "$INSTDIR\mb\default\user.def"
	Delete "$INSTDIR\mb\default\attach.mb"
	
	;系统文件
	Delete "$INSTDIR\convert.mb"
	Delete "$INSTDIR\freewb.bin"
	Delete "$INSTDIR\freewb.bex"
	Delete "$INSTDIR\freewb.chm"
	Delete "$INSTDIR\freewb.dll"
	Delete /REBOOTOK "$INSTDIR\freewb.ime"
	Delete "$INSTDIR\freewb.ini"
	Delete "$INSTDIR\g2b.dat"
	
	;===========================================================================
	Delete "$INSTDIR\unInstallIME.exe"
	Delete "$INSTDIR\unregistry.exe"
	Delete "$INSTDIR\registry.exe"
	
	RMDir "$INSTDIR"

	IfSilent Over
	MessageBox MB_OK "极点五笔卸载完毕,感谢您的试用。  $\r$\n$\r$\n"
Over:
SectionEnd ; end of uninstall section
; eof

引用 caps.nsh 的内容:

SubCaption 0 ": 许可协议"
SubCaption 1 ": 安装选项"
SubCaption 2 ": 安装目录"
SubCaption 3 ": 安装文件"
SubCaption 4 ": 安装完成"
BrandingText "NULLSOFT INSTALL SYSTEM"
MiscButtonText "<>" "取消" "关闭"
LicenseText "" "我同意"
ComponentText "" "  请选择系统安装目录:" "或, 选择组件安装目录:"
InstType /CUSTOMSTRING=CUSTOM
SpaceTexts "需求空间: " "有效空间: "
DirText "" "" "浏览..."
!ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
UninstallText "" "卸载: "
UninstallSubCaption 0 ": 确认"
UninstallSubCaption 1 ": 正在卸载文件"
UninstallSubCaption 2 ": 完成"
UninstallButtonText "卸载"
!endif

InstallButtonText "安装"
DetailsButtonText "显示详细信息"
CompletedText "结束"

点击另存资源文件