nsis安装mysql服务语句_nsis脚本: Tomcat JDK MYSQL

; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines

!define PRODUCT_NAME "Java项目"

!define PRODUCT_VERSION "1.0"

!define PRODUCT_PUBLISHER "Vimesly"

!define PRODUCT_WEB_SITE "http://localhost:50081"

!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\appletviewer.exe"

!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"

!define PRODUCT_UNINST_ROOT_KEY "HKLM"

; 定义系统环境变量的 注册表key值

!define WriteEnvStr_RegKey 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'

; MUI 1.67 compatible ------

!include "MUI.nsh"

; MUI Settings

!define MUI_ABORTWARNING

!define MUI_WELCOMEFINISHPAGE_BITMAP "D:\360Downloads\aa.bmp"

!define MUI_ICON "D:\360Downloads\安装.ico"

!define MUI_UNICON "D:\360Downloads\卸载.ico"

!define MUI_WELCOMEPAGE_TITLE "\r\n 测试项目 1.0 测试版"

!define MUI_WELCOMEPAGE_TEXT "     测试信息测试信息测试信息测试信息测试信息测试信息测试信息测试信息测试信息测试信息测试信息测试信息测试信息测试信息测试信息测试信息测试信息。 \r\n\r\n 软件制作:安会锋(Vimesly) \r\n\r\n $_CLICK"

; Welcome page

!insertmacro MUI_PAGE_WELCOME

; License page

!insertmacro MUI_PAGE_LICENSE "D:\360Downloads\ceshi\doc\协议.txt"

; Directory page

!insertmacro MUI_PAGE_DIRECTORY

; Instfiles page

!insertmacro MUI_PAGE_INSTFILES

; Finish page

!insertmacro MUI_PAGE_FINISH

; Uninstaller pages

!insertmacro MUI_UNPAGE_INSTFILES

; Language files

!insertmacro MUI_LANGUAGE "SimpChinese"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"

OutFile "Setup.exe"

InstallDir "$PROGRAMFILES\Java-web"

InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""

ShowInstDetails show

ShowUnInstDetails show

BrandingText "软件制作:安会锋(vimesly)"

Section "MainSection" SEC01

SetOutPath "$INSTDIR\doc"

SetOverwrite try

File "D:\360Downloads\ceshi\doc\协议.txt"

CreateDirectory "$SMPROGRAMS\Java项目"

CreateShortCut "$SMPROGRAMS\Java项目\Java项目.lnk" "$INSTDIR\doc\协议.txt"

CreateShortCut "$DESKTOP\Java项目.lnk" "$INSTDIR\doc\协议.txt"

SetOutPath "$INSTDIR\jdk1.6\bin"

File "D:\360Downloads\ceshi\jdk1.6\bin\appletviewer.exe"

....... File "D:\360Downloads\ceshi\tomcat\work\Catalina\localhost\_\SESSIONS.ser"

SectionEnd

Section -AdditionalIcons

SetOutPath $INSTDIR

#安装服务

call regExpandStr

call installService

call startService

WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"

CreateShortCut "$SMPROGRAMS\Java项目\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"

CreateShortCut "$SMPROGRAMS\Java项目\Uninstall.lnk" "$INSTDIR\uninst.exe"

SectionEnd

Section -Post

WriteUninstaller "$INSTDIR\uninst.exe"

WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\jdk1.6\bin\appletviewer.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}" "DisplayIcon" "$INSTDIR\jdk1.6\bin\appletviewer.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

;设置环境变量

Function "regExpandStr"

SetOverwrite ifnewer

;设置jdk环境变量

WriteRegExpandStr ${WriteEnvStr_RegKey} "JAVA_HOME" "$INSTDIR\jdk1.6"

;设置catalina_home

WriteRegExpandStr ${WriteEnvStr_RegKey} "CATALINA_HOME" "$INSTDIR\tomcat"

#第一次是使环境变量修改对其他进程有效;刷新环境变量

SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000

SetOverwrite on

functionend

;注册服务

Function "installService"

detailprint "install mysql Service..."

Sleep 2000

SetOutPath "$INSTDIR\tomcat\bin"

nsExec::Exec 'cmd /c service install tomcat6'

nsExec::Exec 'cmd /c sc config tomcat6 start= auto'

detailprint "install tomcat Service success..."

Sleep 2000

SetOutPath "$INSTDIR\mysql\bin"

nsExec::Exec 'cmd /c mysqld3306 install MySQL5.1'

detailprint "install mysql Service success..."

detailprint "install tomcat Service..."

functionend

; 启动服务

Function "startService"

detailprint "start tomcat..."

nsExec::Exec 'cmd /c sc start tomcat6'

detailprint "start tomcat success..."

detailprint "start mysql..."

nsExec::Exec 'cmd /c sc start MySQL5.1'

detailprint "start MySQL5.1 success..."

functionend

;停止服务

Function "un.stopService"

detailprint "正在停止tomcat服务......."

nsExec::Exec 'cmd /c sc stop tomcat6'

detailprint "停止tomcat服务成功......."

detailprint "正在停止mysql服务......."

nsExec::Exec 'cmd /c sc stop MySQL5.1'

detailprint "停止mysql服务成功......."

functionend

;删除服务

Function "un.uninstService"

detailprint "正在卸载tomcat服务......."

nsExec::Exec 'cmd /c sc delete tomcat6'

detailprint "卸载tomcat服务成功......."

detailprint "正在卸载mysql服务......."

nsExec::Exec 'cmd /c sc delete MySQL5.1'

detailprint "卸载mysql服务成功......."

functionend

;清空环境变量

Function "un.emptyRegExpandStr"

#删除 系统环境变量JAVA_HOME 和 CATALINA_HOME

#卸载的时候必须设置JAVA_HOME 和 CATALINA_HOME两个环境系统变量为空,或者删除这两个系统变量。否则会出现NSIS选择系统变量的错误(NSIS会自动选择之前有值的系统变量,而不是选择当前刚设置的系统变量)

detailprint "正在删除相关环境变量......."

WriteRegExpandStr ${WriteEnvStr_RegKey} "JAVA_HOME" ""

sleep 1000

;设置TOMCAT环境变量CATALINA_HOME

WriteRegExpandStr ${WriteEnvStr_RegKey} "CATALINA_HOME" ""

functionend

Function un.onUninstSuccess

HideWindow

MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从你的计算机移除。"

FunctionEnd

Function un.onInit

MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "你确实要完全移除 $(^Name) ,其及所有的组件?" IDYES +2

Abort

FunctionEnd

Section Uninstall

#开始停止/卸载服务

call un.stopService

call un.uninstService

call un.emptyRegExpandStr

#删除所有安装目录文件

detailprint "正在删除安装目录......."

Delete "$INSTDIR\${PRODUCT_NAME}.url"

Delete "$INSTDIR\uninst.exe"

Delete "$INSTDIR\tomcat\work\Catalina\localhost\_\SESSIONS.ser"

......

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"

DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"

SetAutoClose true

SectionEnd

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值