最新消息:

NSIS制作B/S应用的安装程序java

nsis 永恒心锁 2030浏览 0评论
SetCompressor zlib

# Defines
!define REGKEY "SOFTWARE$(^Name)"
!define VERSION 1.0
!define COMPANY 超能公司
!define URL www.XXXX.com

# MUI defines
#!define MUI_ICON logo.ico
#!define MUI_UNICON logo.ico
!define MUI_FINISHPAGE_NOAUTOCLOSE
#定义readme
!define MUI_FINISHPAGE_SHOWREADME $INSTDIRreadme.txt
!define MUI_FINISHPAGE_RUN "$PROGRAMFILESInternet ExplorerIEXPLORE.EXE"
!define MUI_FINISHPAGE_RUN_PARAMETERS 登录主页的url

!define MUI_CUSTOMFUNCTION_GUIINIT CustomGUIInit
!define MUI_UNFINISHPAGE_NOAUTOCLOSE

# Included files
!include Sections.nsh
!include MUI.nsh
!include "LogicLib.nsh"
!include "${NSISDIR}ExamplesSystemSystem.nsh"
!include WinMessages.nsh
# Reserved Files
ReserveFile "${NSISDIR}PluginsBGImage.dll"
ReserveFile "${NSISDIR}PluginsAdvSplash.dll"

# Variables
Var StartMenuGroup

# Installer pages
!insertmacro MUI_PAGE_WELCOME
#!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

# Installer languages
!insertmacro MUI_LANGUAGE SimpChinese

Caption "超能MIS"

Icon "imginstall.ico"
BrandingText " 超能有限公司 -- www.超能.com "
# Installer attributes
OutFile 超能.Exe
InstallDir $PROGRAMFILES超能

!define MUI_HEADERIMAGE
CRCCheck on
XPStyle on
ShowInstDetails show
#nevershow
VIProductVersion 1.0.0.0
VIAddVersionKey /LANG=${LANG_SIMPCHINESE} ProductName 超能system
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey /LANG=${LANG_SIMPCHINESE} CompanyName "${COMPANY}"
VIAddVersionKey /LANG=${LANG_SIMPCHINESE} CompanyWebsite "${URL}"
VIAddVersionKey /LANG=${LANG_SIMPCHINESE} FileVersion ""
VIAddVersionKey /LANG=${LANG_SIMPCHINESE} FileDescription ""
VIAddVersionKey /LANG=${LANG_SIMPCHINESE} LegalCopyright ""
InstallDirRegKey HKLM "${REGKEY}" Path
ShowUninstDetails hide

UninstallText "将要卸载 超能system .点击继续."
UninstallIcon "imguninstall.ico"
var DBPATH
# Installer SQL Server 2000 sections
Section SqlServer SEC0000
 #MessageBox MB_OK $EXEDIR
 #调用第一个信息
 IntOp $9 0 + 1
 call showBg

 StrCpy $DBPATH $INSTDIR
 ;ReadRegStr $0 HKLM "SoftwareMicrosoftMSSQLServerSetup" "SQLPath"
 ReadRegStr $0 HKLM "SoftwareMicrosoftMicrosoft SQL ServerXXXXSetup" "SQLPath"
 StrCmp $0 "" 0 +9
 DetailPrint "正在安装SQL Server 2000 桌面引擎,请等约两分钟。 "
 ExecWait '"$EXEDIRDisk1MSDERelAsetup.exe" DISABLENETWORKPROTOCOLS=0 SAPWD="XXXXXX"

SECURITYMODE=SQL INSTANCENAME="XXXX" DATADIR="$INSTDIR" TARGETDIR="$INSTDIR"'
 DetailPrint "SQL Server 2000 桌面引擎安装完成!"
 IfFileExists $DBPATHMSSQL$$XXXXDataXXXXX.mdf 0 +2
 Delete /REBOOTOK $DBPATHMSSQL$$XXXXXDataXXXXX.mdf
 IfFileExists $DBPATHMSSQL$$XXXXXDataXXXXX_log.LDF 0 +2
 Delete /REBOOTOK $DBPATHMSSQL$$XXXXXDataXXXXX_log.LDF
 goto +2
 StrCpy $DBPATH $0
 IntOp $9 0 + 2
 call showBg
 ExecWait '"net.exe" start MSSQL$$XXXXX'
 ExecWait '"osql.exe" -U sa -P XXXXXX -S .XXXXX -Q "Create Database XXXXX"'
 DetailPrint "正在恢复演示数据!请耐心等待。"
 ExecWait '"osql.exe" -U sa -P styx2008 -S .XXXXX -Q "restore database XXXX from

disk=$'$EXEDIRDisk1XXXX$' with move $'XXXX_Data$' to

$'$DBPATHMSSQL$$XXXXDataXXXX.mdf$', move $'XXXX_Log$' to

$'$DBPATHMSSQL$$XXXXDataXXXX_log.LDF$'"'
 DetailPrint "演示数据恢复完成!"
 IntOp $9 0 + 3
 call showBg

SectionEnd

# Installer jdk1.5.0_06 sections
Section -JDK5 SEC0001
 SetOutPath $INSTDIR
 File readme.txt
 File imginstall.ico

 DetailPrint "正在安装Java虚拟机!"
 SetOutPath "$INSTDIRjdk1.5.0_06"
 SetOverwrite on
 File /r "C:Program FilesJavajdk1.5.0_06*"
 push $9
 IntOp $9 0 + 4
 call showBg
 pop $9
 ;SetOutPath $INSTDIR
 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=0
 WriteRegExpandStr HKLM "SYSTEMCurrentControlSetControlSession ManagerEnvironment"

"JAVA_HOME" "$INSTDIRjdk1.5.0_06"
 WriteRegExpandStr HKLM "SYSTEMCurrentControlSetControlSession ManagerEnvironment"

"TOMCAT_HOME" "$PROGRAMFILESTomcat 5.0"

 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=0
 WriteRegStr HKLM "${REGKEY}Components" JDK5 1

 DetailPrint "Java虚拟机安装完成!"
 push $9
 IntOp $9 0 + 5
 call showBg
 pop $9

SectionEnd
# Installer Tomcat 5.0 sections
Section -Server SEC0002
 IntOp $9 0 + 6
 call showBg
 DetailPrint "正在安装WEB服务器!"
 SetOutPath "$PROGRAMFILESTomcat 5.0"
 SetOverwrite on
 File /r "D:Tomcat 5.0*"
 push $9
 IntOp $9 0 + 7
 call showBg
 pop $9
 ;ReadRegStr $0 HKLM "SYSTEMCurrentControlSetControlSession ManagerEnvironment"

"TOMCAT_HOME"
 ;WriteRegExpandStr HKLM "SYSTEMCurrentControlSetControlSession ManagerEnvironment"

"TOMCAT_HOME" "$PROGRAMFILESTomcat 5.0"
 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment"
#在windows服务中加入”启动服务“项
 ExecWait '"$PROGRAMFILESTomcat 5.0binNetInstall.bat" "$PROGRAMFILESTomcat 5.0bin"

"$INSTDIRjdk1.5.0_06"'
 #ExecWait '"$PROGRAMFILESTomcat 5.0bintomcat5.exe" //IS//XXXX --DisplayName="XXXX"

--Install="$PROGRAMFILESTomcat 5.0bintomcat5.exe" --Jvm=auto --StartMode=jvm --

StopMode=jvm --StartClass=org.apache.catalina.startup.Bootstrap --StartParams=start --

StopClass=org.apache.catalina.startup.Bootstrap --StopParams=stop'
 #ExecWait '"$PROGRAMFILESTomcat 5.0bintomcat5.exe" //IS//XXXX --DisplayName="XXXX"

--Install="$PROGRAMFILESTomcat 5.0bintomcat5.exe" --Jvm="$INSTDIRjdk1.5.0_06

jrebinserverjvm.dll" --StartMode=jvm --StopMode=jvm --

StartClass=org.apache.catalina.startup.Bootstrap --StartParams=start --

StopClass=org.apache.catalina.startup.Bootstrap --StopParams=stop'
 ExecWait '"$PROGRAMFILESTomcat 5.0bintomcat5.exe" //US//XXXX --Description="XXXX" -

-Startup=auto'
 DetailPrint "WEB服务器安装完成!"
 DetailPrint "WEB服务器开始启动!"
 push $9
 IntOp $9 0 + 8
 call showBg
 pop $9
启动tomcat
 ExecWait '"net" start XXXX'
 push $9
 IntOp $9 0 + 9
 call showBg
 pop $9
 DetailPrint "WEB服务器启动完成!"
 WriteRegStr HKLM "${REGKEY}Components" Server 1
 push $9
 IntOp $9 0 + 10
 call showBg
 pop $9

 push $1
 push $0
#读取当前数据库实例的端口,并且写入应用的配置文件
 ReadRegStr $1 HKLM "SoftwareMicrosoftMicrosoft SQL

ServerXXXXMSSQLServerSuperSocketNetLibTcp" "TcpPort"
 StrCmp $1 "" done 0
 ;IfFileExists $PROGRAMFILESTomcat 5.0webappsXXXXWEB-INFNode.driver.xml 0 +2
 FileOpen $0 '$PROGRAMFILESTomcat 5.0webappsXXXXWEB-INFNode.driver.xml' w
 FileWrite $0 '<?xml version="1.0" encoding="utf-8"?>$r$n'
 FileWrite $0 '<driver project-version="1.0"

class="com.microsoft.jdbc.sqlserver.SQLServerDriver">$r$n'
 FileWrite $0 '<url

value="jdbc:microsoft:sqlserver://127.0.0.1:$1;DatabaseName=XXXX"/>$r$n'
 FileWrite $0 '<connectionPool min="1" max="100" />$r$n'
 FileWrite $0 '<login userName="sa" password="XXXX"/>$r$n'
 FileWrite $0 '</driver>'
 FileClose $0
 done:

 pop $1
 pop $0
 ; CopyFiles $INSTDIR*.dat $INSTDIRbackup

SectionEnd

# Installer Shortcut sections
Section -Shortcut SEC0003
 SetOutPath $SMPROGRAMS$StartMenuGroup
 CreateShortcut $SMPROGRAMS$StartMenuGroupbin.lnk "$PROGRAMFILESTomcat 5.0bin"
 CreateShortcut $SMPROGRAMS$StartMenuGroup超能系统.lnk "$PROGRAMFILESInternet

ExplorerIEXPLORE.EXE " "http://127.0.0.1:8080/XXXX/login.jsp"
 CreateShortcut $SMPROGRAMS$StartMenuGroupReadMe.lnk "notepad.exe "

"$INSTDIRreadme.txt"
 WriteRegStr HKLM "${REGKEY}Components" Shortcut 1
 IntOp $9 0 + 11
 call showBg
SectionEnd

Section -post SEC0004
 WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
 SetOutPath $INSTDIR
 WriteUninstaller $INSTDIRuninstall.exe
 SetOutPath $SMPROGRAMS$StartMenuGroup
 CreateShortcut "$SMPROGRAMS$StartMenuGroup$(^UninstallLink).lnk"

$INSTDIRuninstall.exe
 WriteRegStr HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstall$(^Name)"

DisplayName "$(^Name)"
 WriteRegStr HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstall$(^Name)"

DisplayVersion "${VERSION}"
 WriteRegStr HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstall$(^Name)"

Publisher "${COMPANY}"
 WriteRegStr HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstall$(^Name)"

URLInfoAbout "${URL}"
 WriteRegStr HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstall$(^Name)"

DisplayIcon $INSTDIRlogo.ico
 WriteRegStr HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstall$(^Name)"

UninstallString $INSTDIRuninstall.exe
 WriteRegDWORD HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstall$(^Name)"

NoModify 1
 WriteRegDWORD HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstall$(^Name)"

NoRepair 1
 IntOp $9 0 + 12
 call showBg
SectionEnd

# Macro for selecting uninstaller sections
!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
 Push $R0
 ReadRegStr $R0 HKLM "${REGKEY}Components" "${SECTION_NAME}"
 StrCmp $R0 1 0 next${UNSECTION_ID}
 !insertmacro SelectSection "${UNSECTION_ID}"
 GoTo done${UNSECTION_ID}
next${UNSECTION_ID}:
 !insertmacro UnselectSection "${UNSECTION_ID}"
done${UNSECTION_ID}:
 Pop $R0
!macroend
# Uninstaller sections
Section /o un.Server UNSEC0000
 ExecWait '"cd" /d $PROGRAMFILESTomcat 5.0bin'
 ExecWait '"net" stop XXXX'
 ExecWait '"$PROGRAMFILESTomcat 5.0binNetRemove.bat" "$PROGRAMFILESTomcat 5.0bin"'
 Delete /REBOOTOK $INSTDIRreadme.txt
 Delete /REBOOTOK $INSTDIRinstall.ico
 RmDir /r /REBOOTOK "$PROGRAMFILESTomcat 5.0"
 DeleteRegValue HKLM "${REGKEY}Components" Server
SectionEnd

Section /o un.Shortcut UNSEC0001
 Delete /REBOOTOK $SMPROGRAMS$StartMenuGroupbin.lnk
 Delete /REBOOTOK $SMPROGRAMS$StartMenuGroup超能系统登录.lnk
 Delete /REBOOTOK $SMPROGRAMS$StartMenuGroupReadMe.lnk
 RmDir /r /REBOOTOK "$SMPROGRAMS$StartMenuGroup"
 DeleteRegValue HKLM "${REGKEY}Components" Shortcut
SectionEnd

Section /o un.JDK5 UNSEC0002
 RmDir /r /REBOOTOK "$INSTDIRjdk1.5.0_06"
 DeleteRegValue HKLM "SYSTEMCurrentControlSetControlSession ManagerEnvironment"

"JAVA_HOME"
 DeleteRegValue HKLM "SYSTEMCurrentControlSetControlSession ManagerEnvironment"

"TOMCAT_HOME"
 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=0
 DeleteRegValue HKLM "${REGKEY}Components" JDK5
SectionEnd

Section un.post UNSEC0003
 DeleteRegKey HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstall$(^Name)"
 Delete /REBOOTOK "$SMPROGRAMS$StartMenuGroup$(^UninstallLink).lnk"
 Delete /REBOOTOK $INSTDIRuninstall.exe
 DeleteRegValue HKLM "${REGKEY}" Path
 DeleteRegKey /IfEmpty HKLM "${REGKEY}Components"
 DeleteRegKey /IfEmpty HKLM "${REGKEY}"
 RmDir /REBOOTOK $SMPROGRAMS$StartMenuGroup
 RmDir /REBOOTOK $INSTDIR
SectionEnd

# Installer functions
Function CustomGUIInit
 CreateFont $R1 "华文中宋" 15 500 #/NORMAL
 IntOp $9 0 + 0
 call showBg
 CALL repositionWindow
 ;System::Call "User32::SetWindowPos(i, i, i, i, i, i, i) b ($HWNDPARENT, -1, 0, 0, 0, 0,

${SWP_NOOWNERZORDER}|${SWP_NOSIZE})"

FunctionEnd

Function .onGUIEnd
 BGImage::Destroy

FunctionEnd

Function .onInit
 InitPluginsDir
 StrCpy $StartMenuGroup "超能系统"
 Push $R1

 File /oname=$PLUGINSDIRbg.bmp "imgbg.bmp"
 File /oname=$PLUGINSDIRspltmp.bmp imgMainSplash.bmp
 advsplash::show 1000 600 400 -1 $PLUGINSDIRspltmp
 Pop $R1
 Pop $R1
FunctionEnd

# Uninstaller functions
Function un.onInit

 ReadRegStr $INSTDIR HKLM "${REGKEY}" Path
 StrCpy $StartMenuGroup "超能系统"
 !insertmacro SELECT_UNSECTION Server ${UNSEC0000}
 !insertmacro SELECT_UNSECTION Shortcut ${UNSEC0001}
 !insertmacro SELECT_UNSECTION JDK5 ${UNSEC0002}

FunctionEnd
Function repositionWindow
 ;Save existing register values to the stack
 Push $0
 Push $1
 Push $2
 Push $3
 Push $4
 Push $5
 Push $6
 Push $7
 Push $8
; !define SPI_GETWORKAREA 0x0030
; !define SWP_NOSIZE 0x0001
; !define SWP_NOOWNERZORDER 0x0200
 ; Reposition window in the lower left
 ; Create RECT struct
 System::Call "*${stRECT} .r1"
 ; Find Window info for the window we're displaying
 System::Call "User32::GetWindowRect(i, i) i ($HWNDPARENT, r1) .r2"
 ; Get left/top/right/bottom
 System::Call "*$1${stRECT} (.r2, .r3, .r4, .r5)"

 ; Calculate width/height of our window
 IntOp $2 $4 - $2 ; $2 now contains the width
 IntOp $3 $5 - $3 ; $3 now contains the height

 ; Determine the screen work area
 System::Call "User32::SystemParametersInfo(i, i, i, i) i (${SPI_GETWORKAREA}, 0, r1, 0)

.r4"
 ; Get left/top/right/bottom
 System::Call "*$1${stRECT} (.r4, .r5, .r6, .r7)"

 System::Free $1

 ; Right side of screen - window - 10
 IntOp $0 $6 - $2
 IntOp $0 $0 / 2
 ; Left side of screen + 10
 ;IntOp $0 $4 + 10

 ; Bottom of screen - window - 5
 IntOp $1 $7 - $3
 IntOp $1 $1 / 2
 IntOp $8 $7 / 10
 IntOp $1 $1 + $8

 System::Call "User32::SetWindowPos(i, i, i, i, i, i, i) b ($HWNDPARENT, -1, $0, $1, 0,

0, ${SWP_NOOWNERZORDER}|${SWP_NOSIZE})"

 ;Restore register values from the stack
 Pop $8
 Pop $7
 Pop $6
 Pop $5
 Pop $4
 Pop $3
 Pop $2
 Pop $1
 Pop $0
FunctionEnd
Function showBg
 BgImage::Clear /NOUNLOAD
 BgImage::SetBg /NOUNLOAD /FILLSCREEN $PLUGINSDIRbg.bmp
 ${Switch} $9
 ${Case} 0
 BGImage::AddText /NOUNLOAD "  信息1。" $R1 0 0 0 40 130 990 230
 ${Break}
 ${Case} 1
 ;BGImage::AddImage /NOUNLOAD 38 130 $EXEDIRimg1.bmp
 BGImage::AddText /NOUNLOAD "  信息2 " $R1 0 0 0 40 130 990 230
 ${Break}
 ${Case} 2
 BGImage::AddText /NOUNLOAD "信息3" $R1 0 0 0 200 130 990 230
 ${Break}
 ${Case} 3
 BGImage::AddText /NOUNLOAD "信息4" $R1 0 0 0 220 150 990 230
 ${Break}
 ${Case} 4
 BGImage::AddText /NOUNLOAD "   信息5" $R1 0 0 0 180 130 850 230
 ${Break}
 ${Case} 5
 BGImage::AddText /NOUNLOAD "  信息6" $R1 0 0 0 120 130 880 230
 ${Break}
 ${Case} 6
 BGImage::AddText /NOUNLOAD "“信息7" $R1 0 0 0 330 170 990 230
 ${Break}
 ${Case} 7
 BGImage::AddText /NOUNLOAD "信息8" $R1 0 0 0 400 170 990 230
 ${Break}
 ${Case} 8
 BGImage::AddText /NOUNLOAD "信息9" $R1 0 0 0 300 150 990 230
 ${Break}
 ${Case} 9
 BGImage::AddText /NOUNLOAD "信息10" $R1 0 0 0 400 170 990 230
 ${Break}

 ${EndSwitch}
 BGImage::Redraw /NOUNLOAD
FunctionEnd

/*Function WriteEnvStr
 Exch $1 ; $1 has environment variable value
 Exch
 Exch $0 ; $0 has environment variable name
 Push $2

 Call IsNT
 Pop $2
 StrCmp $2 1 WriteEnvStr_NT
 ; Not on NT
 StrCpy $2 $WINDIR 2 ; Copy drive of windows (c:)
 FileOpen $2 "$2autoexec.bat" a
 FileSeek $2 0 END
 FileWrite $2 "$r$nSET $0=$1$r$n"
 FileClose $2
 SetRebootFlag true
 Goto WriteEnvStr_done

 WriteEnvStr_NT:
 ;WriteRegExpandStr ${WriteEnvStr_RegKey} $0 $1
 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE}
 0 "STR:Environment" /TIMEOUT=5000

 WriteEnvStr_done:
 Pop $2
 Pop $0
 Pop $1
FunctionEnd*/

# Installer Language Strings
# TODO Update the Language Strings with the appropriate translations.

LangString ^UninstallLink ${LANG_SIMPCHINESE} "Uninstall $(^Name)"
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » NSIS制作B/S应用的安装程序java

您必须 登录 才能发表评论!