NSIS安装文件,需要的拿走

;---------------------------------------
!define PRODUCT_NAME "国家知识产权局题库管理系统"
!define APP_NAME "questionbank"
!define PRODUCT_WEB_SITE "http://localhost:8080/EXAMQUESTION/login.jsp"
!define PRODUCT_VERSION "1.0"
!define ALL_USERS
!include WriteEnvStr.nsh
;----------------------------------------
SetCompressor zlib

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
Caption "${PRODUCT_NAME}"
Icon "${NSISDIR}/Contrib/Graphics/Icons/modern-install.ico"
OutFile "Setup.exe"
LoadLanguageFile "${NSISDIR}/Contrib/Language files/SimpChinese.nlf"

CRCCheck on
SilentInstall normal
XPStyle on
AutoCloseWindow true
ShowInstDetails show

InstallDir "c:/questionbank"
InstallDirRegKey HKLM "Software/LineManage" "Install_Dir"
LicenseText "如果你接受所有协议条款,选择 [我愿意] 继续。你必须接受协议才能安装 $(^Name)。"
LicenseData "licence.txt"

RequestExecutionLevel user
;--------------------------------
Page license
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles
;--------------------------------
Section "安装${PRODUCT_NAME}"
WriteRegStr HKLM "SOFTWARE/${APP_NAME}" "Install_Dir" "$INSTDIR"
WriteRegStr HKLM "Software/Microsoft/Windows/CurrentVersion/Uninstall/${APP_NAME}" "DisplayName" "${PRODUCT_NAME} ${PRODUCT_VERSION}"
WriteRegStr HKLM "Software/Microsoft/Windows/CurrentVersion/Uninstall/${APP_NAME}" "UninstallString" '"$INSTDIR/uninstall.exe"'

SetOutPath $INSTDIR
File /r jdk
File /r tomcat
File /r mysql
File /r ico
call installShortcut
call addEnv
Call installService
Call startService
WriteUninstaller "uninstall.exe"
SectionEnd
;--------------------------------
UninstallText "删除${PRODUCT_NAME}?单击 next 继续."
UninstallIcon "${NSISDIR}/Contrib/Graphics/Icons/modern-uninstall.ico"

Section "Uninstall"
DeleteRegKey HKLM "Software/Microsoft/Windows/CurrentVersion/Uninstall/${APP_NAME}"
DeleteRegKey HKLM "SOFTWARE/${APP_NAME}"
call un.stopService
call un.removeService
call un.removeEnv
RMDir /r "$SMPROGRAMS/${APP_NAME}"
RMDir /r "$INSTDIR"
SectionEnd
;------------------------------------
Function .onInstSuccess
ExecShell open "http://localhost:8080/EXAMQUESTION/login.jsp"
FunctionEnd
;------------------------------------
function "installShortcut"
WriteIniStr "$INSTDIR/${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateDirectory "$SMPROGRAMS/${APP_NAME}"
CreateShortCut "$SMPROGRAMS/${APP_NAME}/启动${APP_NAME}.lnk" "http://localhost:8080/EXAMQUESTION/login.jsp" "" "$INSTDIR/ico/ico.ico"
CreateShortCut "$SMPROGRAMS/${APP_NAME}/卸载${APP_NAME}.lnk" "$INSTDIR/uninstall.exe"
CreateShortCut "$DESKTOP/国家知识产权局题库管理系统.lnk" "http://localhost:8080/EXAMQUESTION/login.jsp" "" "$INSTDIR/ico/ico.ico"
functionend
;-----------------------------------
function "addEnv"
Push JAVA_HOME
Push "$INSTDIR/jdk"
Call WriteEnvStr
Push CATALINA_HOME
Push "$INSTDIR/tomcat"
Call WriteEnvStr

StrCpy $R0 "$INSTDIR/jdk"
StrCpy $R1 "$INSTDIR/tomcat"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("JAVA_HOME", R0).r2'
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("CATALINA_HOME", R1).r2'
functionend
;-----------------------------------
;注意,window的服务名称中不能有下划线
function "installService"
ExecWait "$INSTDIR/mysql/bin/mysqld --install MysqlLM --defaults-file=$INSTDIR/mysql/my.ini"
SetOutPath "$INSTDIR/tomcat/bin"
ExecWait "service.bat install"
ExecWait "sc config tomcat6 start= auto"
functionend
;-------------------------------------
function "startService"
ExecWait "net start MysqlLM"
ExecWait "net start tomcat6"
ExecWait "net stop tomcat6"
ExecWait "net start tomcat6"
functionend
;-------------------------------------
function "un.stopService"
ExecWait "net stop MysqlLM"
ExecWait "net stop tomcat6"
functionend
;-----------------------------------
function "un.removeService"
ExecWait "$INSTDIR/mysql/bin/mysqld --remove MysqlLM"
ExecWait "$INSTDIR/tomcat/bin/service.bat remove tomcat6"
functionend
;---------------------------------
function "un.removeEnv"
Push JAVA_HOME
Call un.DeleteEnvStr
Push CATALINA_HOME
Call un.DeleteEnvStr
functionend

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值