当前位置:   article > 正文

nsis创建新界面,自定义事件,执行bat脚本,读写xml_nsis setautoclose

nsis setautoclose

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

; 安装程序初始定义常量
!define PRODUCT_NAME “测试”
!define PRODUCT_VERSION “3.0.0”
!define PRODUCT_PUBLISHER “XXX科技有限公司”
!define PRODUCT_WEB_SITE “http://www.baidu.com”
!define PRODUCT_DIR_REGKEY “Software\Microsoft\Windows\CurrentVersion\App Paths\redis-benchmark.exe”
!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

; ------ MUI 现代界面定义 (1.67 版本以上兼容) ------
!include “MUI.nsh”
!include “LogicLib.nsh”
!include “WinMessages.nsh”
!include “nsDialogs.nsh”

; MUI 预定义常量
!define MUI_ABORTWARNING
!define MUI_ICON “D:\sy-bi-config\app\resources\logo0.ico”
!define MUI_UNICON “${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico”

!ifndef TARGETDIR
!ifdef NSIS_UNICODE
!define TARGETDIR “F:\NSIS\Plugins\binU”
!else
!define TARGETDIR “F:\NSIS\Plugins\bin”
!endif
!endif

!addplugindir “${TARGETDIR}”
!addplugindir “F:\NSIS\Plugins\nsexec.dll”
Var hCtl_welecom
Var hCtl_welecom_update
Var hCtl_welecom_install
Var hCtl_welecom_Label1
Var hCtl_welecom_Bitmap1
Var hCtl_welecom_Bitmap1_hImage
Var checkValue

!define MUI_PAGE_CUSTOMFUNCTION_PRE Pre
!define MUI_PAGE_CUSTOMFUNCTION_SHOW Show
;!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leave
!insertmacro MUI_PAGE_WELCOME

!define MUI_PAGE_CUSTOMFUNCTION_PRE compre
!insertmacro MUI_PAGE_LICENSE “F:\ce\协议许可.rtf”
!insertmacro MUI_PAGE_DIRECTORY

Page Custom test ;这里就是自定义页面插入的语句
Var dialog ;下面这几个都是自己定义的变量,这是NSIS自定义变量的格式
Var editcontrol
Var label
Var hwnd
Var User
Var UNINSTALL_PROG
Var OLD_VER
Var OLD_PATH
Var OldPort
Var btn
var ApiPort
var Ipoport
!define AF_INET 2
!define SOCK_STREAM 1
!define IPPROTO_TCP 6
; 安装过程页面
!insertmacro MUI_PAGE_INSTFILES
; 安装完成页面
!define MUI_FINISHPAGE_RUN “http://localhost:$User”
!insertmacro MUI_PAGE_FINISH

; 安装卸载过程页面
!insertmacro MUI_UNPAGE_INSTFILES

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

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

Name “KaTeX parse error: Undefined control sequence: \SYSDBI at position 51: … InstallDir "D:\̲S̲Y̲S̲D̲B̲I̲" InstallDirReg…{PRODUCT_UNINST_KEY}” " "
;安装界面最下方线条文字
BrandingText “XXX科技有限公司(http://www.baidu.com)”

Section “SETBack”
MessageBox MB_ICONINFORMATION|MB_OK “ce1”
${If} c h e c k V a l u e = = 1 n s i s X M L : : c r e a t e ; 不 管 是 读 还 是 写 都 要 有 n s i s X M L : : l o a d " checkValue == 1 nsisXML::create ;不管是读还是写都要有 nsisXML::load " checkValue==1nsisXML::create;nsisXML::load"INSTDIR\resources\server\tomcat\conf\server.xml"
IntCmp $0 0 notFound
nsisXML::select ‘/Server/Service/Connector[@protocol=“HTTP/1.1”]’
nsisXML::getAttribute “port”
StrCpy $User $3
nsisXML::release $2
nsisXML::release $0
Goto end

notFound:
DetailPrint “XPath not resolved”
end:
nsisXML::create ;不管是读还是写都要有
nsisXML::load “$INSTDIR\server.xml”
IntCmp $0 0 notFound0
nsisXML::select ‘/Connector[@protocol=“HTTP/1.1”]’
nsisXML::getAttribute “port”
StrCpy $OldPort $3
nsisXML::release $2
nsisXML::release 0 G o t o e n d 0 n o t F o u n d 0 : D e t a i l P r i n t " X P a t h n o t r e s o l v e d " e n d 0 : n s E x e c : : E x e c ′ " 0 Goto end0 notFound0: DetailPrint "XPath not resolved" end0: nsExec::Exec '" 0Gotoend0notFound0:DetailPrint"XPathnotresolved"end0:nsExec::Exec"INSTDIR\back.bat" $OldPort’
;Exec ‘“D:\sy-bi-config\app\dist\win-unpacked\back.bat” 0’
${EndIf}

Sectionend

Section “MainSection” SEC01
SectionEnd

Section -AdditionalIcons
SetOutPath I N S T D I R W r i t e I n i S t r " INSTDIR WriteIniStr " INSTDIRWriteIniStr"INSTDIR${PRODUCT_NAME}.url" “InternetShortcut” “URL” “ P R O D U C T W E B S I T E " C r e a t e D i r e c t o r y " {PRODUCT_WEB_SITE}" CreateDirectory " PRODUCTWEBSITE"CreateDirectory"SMPROGRAMS\My application”
CreateShortCut “KaTeX parse error: Undefined control sequence: \My at position 11: SMPROGRAMS\̲M̲y̲ ̲application\Web…INSTDIR${PRODUCT_NAME}.url”
CreateShortCut “KaTeX parse error: Undefined control sequence: \My at position 11: SMPROGRAMS\̲M̲y̲ ̲application\Uni…INSTDIR\uninst.exe”
SectionEnd

Section -Post
WriteUninstaller “$INSTDIR\uninst.exe”
WriteRegStr P R O D U C T U N I N S T R O O T K E Y " {PRODUCT_UNINST_ROOT_KEY} " PRODUCTUNINSTROOTKEY"{PRODUCT_UNINST_KEY}" “DisplayName” “$(^Name)”
WriteRegStr P R O D U C T U N I N S T R O O T K E Y " {PRODUCT_UNINST_ROOT_KEY} " PRODUCTUNINSTROOTKEY"{PRODUCT_UNINST_KEY}" “UninstallString” “$INSTDIR\uninst.exe”
WriteRegStr P R O D U C T U N I N S T R O O T K E Y " {PRODUCT_UNINST_ROOT_KEY} " PRODUCTUNINSTROOTKEY"{PRODUCT_UNINST_KEY}" “DisplayVersion” “${PRODUCT_VERSION}”
WriteRegStr P R O D U C T U N I N S T R O O T K E Y " {PRODUCT_UNINST_ROOT_KEY} "

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/112627
推荐阅读
相关标签
  

闽ICP备14008679号