1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015 |
-
- !include "StrFunc.nsh"
- !include "WordFunc.nsh"
- ${StrRep}
- ${StrStr}
- !include "LogicLib.nsh"
- !include "nsDialogs.nsh"
- !include "common.nsh"
- !include "x64.nsh"
- !include "MUI.nsh"
- !include "WinVer.nsh"
- !include "commonfunc.nsh"
- !insertmacro MUI_LANGUAGE "SimpChinese"
- VIProductVersion "${PRODUCT_VERSION}"
- VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
- VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
- VIAddVersionKey "CompanyName" "${PRODUCT_PUBLISHER}"
- VIAddVersionKey "FileVersion" "${PRODUCT_VERSION}"
- VIAddVersionKey "InternalName" "${EXE_NAME}"
- VIAddVersionKey "FileDescription" "${PRODUCT_NAME}"
- VIAddVersionKey "LegalCopyright" "${PRODUCT_LEGAL}"
- !define INSTALL_PAGE_CONFIG 0
- ;!define INSTALL_PAGE_LICENSE 1
- !define INSTALL_PAGE_PROCESSING 1
- !define INSTALL_PAGE_FINISH 2
- !define INSTALL_PAGE_UNISTCONFIG 3
- !define INSTALL_PAGE_UNISTPROCESSING 4
- !define INSTALL_PAGE_UNISTFINISH 5
- Page custom DUIPage
- UninstPage custom un.DUIPage
- Var hInstallDlg
- Var hInstallSubDlg
- Var sCmdFlag
- Var sCmdSetupPath
- Var sSetupPath
- Var sReserveData
- Var InstallState
- Var UnInstallValue
- Var basedir
- Var datadir
- Var logError
- Var buildModelPath
- Var profilePath
- Var buildCallPath
- Var dbpath
- Var logpath
- Var binPath
- Var javaPath
- Var temp11
- Var temp12
- Var OLD_VER
- Var step
- ;在安装程序运行前的回调函数前实现
- Function .onInit
- System::Call 'kernel32::CreateMutexA(i 0, i 0, t"Winsnap_installer") i .r1 ?e'
- Pop $R0
- StrCmp $R0 0 +3
- MessageBox MB_OK|MB_USERICON '有一个安装向导已经运行,请勿重复打开'
- Abort
- ${IfNot} ${AtLeastWin10}
- MessageBox MB_OK|MB_USERICON '本程序只能安装在windows-10(64位)系统上'
- Abort
- ${EndIf}
- ReadRegStr $OLD_VER HKLM "SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_PATHNAME}" "DisplayVersion"
- ${IF} $OLD_VER != ""
- ${VersionCompare} $OLD_VER ${PRODUCT_VERSION} $R0
- ${If} $R0 == "0"
- MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},版本 $OLD_VER 已安装在计算机中。如需重新安装,请卸载已有的安装'
- Quit
- ${EndIf}
- ${If} $R0 == "1"
- MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},版本 $OLD_VER 已安装在计算机中。如需重新安装,请卸载已有的安装'
- ;MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},您安装的版本是 ${PRODUCT_VERSION} 小于版本 $OLD_VER '
- Quit
- ${EndIf}
- ${If} $R0 == "2"
- MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},版本 $OLD_VER 已安装在计算机中。如需重新安装,请卸载已有的安装'
- ;MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},您安装的版本是 ${PRODUCT_VERSION} 大于版本 $OLD_VER '
- Quit
- ${EndIf}
- ${EndIf}
- FunctionEnd
- Function un.onInit
- System::Call 'kernel32::CreateMutexA(i 0, i 0, t"Winsnap_installer") i .r1 ?e'
- Pop $R0
- StrCmp $R0 0 +3
- MessageBox MB_OK|MB_USERICON '有一个卸载向导已经运行,请勿重复打开'
- Abort
- FunctionEnd
- Function DUIPage
- StrCpy $InstallState "0"
- InitPluginsDir
- SetOutPath "$PLUGINSDIR"
- File "${INSTALL_LICENCE_FILENAME}"
- File "${INSTALL_RES_PATH}"
- File /oname=logo.ico "${INSTALL_ICO}" #
- nsNiuniuSkin::InitSkinPage "$PLUGINSDIR\" "${INSTALL_LICENCE_FILENAME}"
- Pop $hInstallDlg
-
- Call GenerateSetupAddress
-
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" "$INSTDIR\"
- Call OnRichEditTextChange
- nsNiuniuSkin::SetWindowTile $hInstallDlg "${PRODUCT_NAME}安装程序"
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_CONFIG}
-
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "licensename" "text" "《四维深时本地版用户许可协议》"
-
- Call BindUIControls
- nsNiuniuSkin::ShowPage 0
- FunctionEnd
- Function un.DUIPage
- StrCpy $InstallState "0"
- InitPluginsDir
- SetOutPath "$PLUGINSDIR"
- File "${INSTALL_RES_PATH}"
- File /oname=logo.ico "${UNINSTALL_ICO}"
- nsNiuniuSkin::InitSkinPage "$PLUGINSDIR\" ""
- Pop $hInstallDlg
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTCONFIG}
- nsNiuniuSkin::SetWindowTile $hInstallDlg "${PRODUCT_NAME}卸载程序"
- nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390s
- Call un.BindUnInstUIControls
-
-
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "chkAutoRun" "selected" "true"
-
- nsNiuniuSkin::ShowPage 0
-
- FunctionEnd
- Function un.BindUnInstUIControls
- GetFunctionAddress $0 un.ExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnUninstalled" $0
-
- GetFunctionAddress $0 un.onUninstall
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnUnInstall" $0
-
- GetFunctionAddress $0 un.ExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnClose" $0
-
- GetFunctionAddress $0 un.OnBtnMin
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnFinishedMin" $0
- GetFunctionAddress $0 un.BtnDirPre
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirPre" $0
- FunctionEnd
- Function BindUIControls
- GetFunctionAddress $0 OnExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseClose" $0
-
- GetFunctionAddress $0 OnBtnMin
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseMin" $0
-
-
- GetFunctionAddress $0 OnBtnLicenseClick
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnAgreement" $0
-
- GetFunctionAddress $0 OnExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirClose" $0
-
- GetFunctionAddress $0 OnExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseCancel" $0
-
- GetFunctionAddress $0 OnBtnMin
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirMin" $0
-
- GetFunctionAddress $0 OnBtnSelectDir
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnSelectDir" $0
-
- GetFunctionAddress $0 OnBtnDirPre
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirPre" $0
-
- GetFunctionAddress $0 OnBtnShowConfig
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnAgree" $0
-
- GetFunctionAddress $0 OnBtnCancel
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirCancel" $0
-
- GetFunctionAddress $0 OnBtnInstall
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnInstall" $0
-
- GetFunctionAddress $0 OnExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnDetailClose" $0
-
- GetFunctionAddress $0 OnBtnMin
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnDetailMin" $0
- GetFunctionAddress $0 OnFinished
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnRun" $0
-
- GetFunctionAddress $0 OnBtnMin
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnFinishedMin" $0
-
- GetFunctionAddress $0 OnExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnClose" $0
-
- GetFunctionAddress $0 OnCheckLicenseClick
- nsNiuniuSkin::BindCallBack $hInstallDlg "chkAgree" $0
-
- GetFunctionAddress $0 OnBtnShowMore
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnShowMore" $0
-
- GetFunctionAddress $0 OnBtnHideMore
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnHideMore" $0
-
- GetFunctionAddress $0 OnSysCommandCloseEvent
- nsNiuniuSkin::BindCallBack $hInstallDlg "syscommandclose" $0
-
- GetFunctionAddress $0 OnRichEditTextChange
- nsNiuniuSkin::BindCallBack $hInstallDlg "editDir" $0
- FunctionEnd
- Function OnRichEditTextChange
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "editDir" "text"
- Pop $0
- StrCpy $INSTDIR "$0"
-
- Call onVerifyInstDir
- Pop $0
- ${If} $0 == 1
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "不能包含中文路径"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- goto TextChangeAbort
- ${EndIf}
- ${If} $0 == 2
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "路径不能为空"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- goto TextChangeAbort
- ${EndIf}
- Call IsSetupPathIlleagal
- ${If} $R5 == "0"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "路径错误"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- goto TextChangeAbort
- ${EndIf}
-
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#FF999999"
- ${If} $R0 > 1024
-
- IntOp $R1 $R0 % 1024
- IntOp $R0 $R0 / 1024;
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "剩余空间:$R0.$R1GB"
- ${Else}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "剩余空间:$R0.$R1MB"
- ${endif}
-
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
- Pop $0
- ${If} $0 == "1"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "true"
- ${Else}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- ${EndIf}
-
- TextChangeAbort:
- FunctionEnd
- Function OnCheckLicenseClick
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
- Pop $0
- ${If} $0 == "0"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "true"
- ${Else}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- ${EndIf}
- FunctionEnd
- Function OnBtnLicenseClick
- ;nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_LICENSE}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "visible" "true"
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "moreconfiginfo" "visible"
- Pop $0
- ${If} $0 = 0
- ;pos="10,35,560,405"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "pos" "5,35,475,385"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "editLicense" "height" "270"
- ${Else}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "pos" "5,35,475,495"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "editLicense" "height" "375"
- ${EndIf}
-
- FunctionEnd
- Section "silentInstallSec" SEC01
- #MessageBox MB_OK|MB_ICONINFORMATION "Test silent install. you can add your silent install code here."
- SectionEnd
- Function ShowMsgBox
- nsNiuniuSkin::InitSkinSubPage "msgBox.xml" "btnOK" "btnCancel,btnClose"
- Pop $hInstallSubDlg
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblTitle" "text" "提示"
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblMsg" "text" "$R8"
- ${If} "$R7" == "1"
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "hlCancel" "visible" "true"
- ${EndIf}
-
- nsNiuniuSkin::ShowSkinSubPage 0
- FunctionEnd
- Function OnBtnInstall
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
- Pop $0
- StrCpy $0 "1"
-
- StrCmp $0 "0" InstallAbort 0
-
- nsProcess::_FindProcess "${EXE_NAME_EXT}"
- Pop $R0
-
- ${If} $R0 == 0
- StrCpy $R8 "${PRODUCT_NAME} 正在运行,请退出后重试!"
- StrCpy $R7 "0"
- Call ShowMsgBox
- goto InstallAbort
- ${EndIf}
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "editDir" "text"
- Pop $0
- StrCmp $0 "" InstallAbort 0
-
- Call AdjustInstallPath
- StrCpy $sSetupPath "$INSTDIR"
-
- Call IsSetupPathIlleagal
- ${If} $R5 == "0"
- StrCpy $R8 "路径错误,请使用正确的路径安装!"
- StrCpy $R7 "0"
- Call ShowMsgBox
- goto InstallAbort
- ${EndIf}
- ${If} $R5 == "-1"
- StrCpy $R8 "目标磁盘空间不足,请使用其他的磁盘安装!"
- StrCpy $R7 "0"
- Call ShowMsgBox
- goto InstallAbort
- ${EndIf}
-
-
- nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "false"
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_PROCESSING}
-
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "min" "0"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "max" "100"
-
- #Call BakFiles
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" "正在安装"
- GetFunctionAddress $0 ExtractFunc
- BgWorker::CallAndWait
-
-
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkShotcut" "selected"
- #Pop $R0
- # ${If} $R0 == "1"
- # SetShellVarContext all
- # CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${EXE_NAME}"
- # SetShellVarContext current
- # ${EndIf}
- SetShellVarContext all
- CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${EXE_NAME}"
- SetShellVarContext current
- Call CreateAppShortcut
- Call CreateUninstall
-
-
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "true"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" "正在初始化..."
- GetFunctionAddress $0 OnEnvInstall
- BgWorker::CallAndWait
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" "正在初始化服务..."
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_pos" "text" ""
- GetFunctionAddress $0 installService
- BgWorker::CallAndWait
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" "初始化完成"
- StrCpy $InstallState "1"
- #Call OnFinished
-
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_FINISH}
- InstallAbort:
- FunctionEnd
- Function ExtractCallback
- Pop $1
- Pop $2
- System::Int64Op $1 * 100
- Pop $3
- System::Int64Op $3 / $2
- Pop $0
-
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "value" "$0"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_pos" "text" "$0%"
- ${If} $1 == $2
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "value" "100"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_pos" "text" "100%"
- ${EndIf}
- FunctionEnd
- Function OnSysCommandCloseEvent
- Call OnExitDUISetup
- FunctionEnd
- Function OnExitDUISetup
- ${If} $InstallState == "0"
- StrCpy $R8 "确定要停止安装吗?"
- StrCpy $R7 "1"
- Call ShowMsgBox
- pop $0
- ${If} $0 == 0
- goto endfun
- ${EndIf}
- ${EndIf}
- nsNiuniuSkin::ExitDUISetup
- endfun:
- FunctionEnd
- Function OnBtnMin
- SendMessage $hInstallDlg ${WM_SYSCOMMAND} 0xF020 0
- FunctionEnd
- Function OnBtnCancel
- nsNiuniuSkin::ExitDUISetup
- FunctionEnd
- Function OnEnvInstall
- EnVar::SetHKLM
- EnVar::AddValue FDMGEA_HOME "$INSTDIR"
- ;EnVar::SetHKLM
- ;EnVar::AddValue JAVA_HOME "$INSTDIR\jdk1.8"
- EnVar::SetHKLM
- EnVar::AddValue MYSQL_HOME "$INSTDIR\mysql"
- EnVar::SetHKLM
- EnVar::AddValue REDIS_HOME "$INSTDIR\redis"
- EnVar::SetHKLM
- EnVar::AddValue 4DKK_HOME "$INSTDIR\CGAII"
- EnVar::SetHKLM
- EnVar::AddValue MONGODB_HOME "$INSTDIR\mongodb"
- ;EnVar::SetHKLM
- ;EnVar::AddValue CLASS_PATH ".;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar"
- EnVar::SetHKLM
- ;EnVar::AddValue "Path" "$INSTDIR\jdk1.8\bin;$INSTDIR\mysql\bin;$INSTDIR\mongodb\bin;$INSTDIR\redis;$INSTDIR\CGAII;$INSTDIR\CGAII\lib;"
- EnVar::AddValue "Path" "$INSTDIR\mysql\bin;$INSTDIR\mongodb\bin;$INSTDIR\redis;$INSTDIR\CGAII;$INSTDIR\CGAII\lib;"
- SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
- ;nsExec::ExecToStack '"$INSTDIR\tools\env_install.bat" $INSTDIR '
-
- FunctionEnd
- Function un.OnEnvDownInstall
- EnVar::SetHKLM
- EnVar::Delete "FDMGEA_HOME" "$INSTDIR"
- ;EnVar::Delete "JAVA_HOME" "$INSTDIR\jdk1.8"
- EnVar::Delete "MYSQL_HOME" "$INSTDIR\mysql"
- EnVar::Delete "REDIS_HOME" "$INSTDIR\redis"
- EnVar::Delete "4DKK_HOME" "$INSTDIR\CGAII"
- EnVar::Delete "MONGODB_HOME" "$INSTDIR\mongodb"
- ;EnVar::Delete "CLASS_PATH" "%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar"
- ;EnVar::DeleteValue "PATH" "%JAVA_HOME%\bin"
- EnVar::DeleteValue "PATH" "$INSTDIR\mysql\bin"
- EnVar::DeleteValue "PATH" "$INSTDIR\mongodb\bin"
- EnVar::DeleteValue "PATH" "$INSTDIR\redis"
- EnVar::DeleteValue "PATH" "$INSTDIR\CGAII"
- EnVar::DeleteValue "PATH" "$INSTDIR\CGAII\lib"
- ;nsExec::ExecToStack '"$INSTDIR\tools\uninstall.bat" $INSTDIR '
- FunctionEnd
- Function un.installService
-
- ${If} $sReserveData == 1
- ; CreateDirectory $INSTDIR\USER_DATA\static
- ; CreateDirectory $INSTDIR\USER_DATA\pro
- ;CopyFiles /SILENT $INSTDIR\4DKK_PROGRAM_STATIC\*.* $INSTDIR\USER_DATA\static
- ;CopyFiles /SILENT $INSTDIR\4DKK_PROGRAM_DATA\*.* $INSTDIR\USER_DATA\pro
- ${EndIf}
- nsExec::ExecToStack '"$INSTDIR\tools\unservice.bat" $INSTDIR '
- SimpleSC::ExistsService "lasermongodb"
- Pop $0
- ${If} $0 == 0
- SimpleSC::StopService "lasermongodb" 0 30
- SimpleSC::RemoveService "lasermongodb"
- ${EndIf}
- SimpleSC::ExistsService "lasermysql"
- Pop $0
- ${If} $0 == 0
- SimpleSC::StopService "lasermysql" 0 30
- SimpleSC::RemoveService "lasermysql"
- ${EndIf}
- SimpleSC::ExistsService "laserredis"
- Pop $0
- ${If} $0 == 0
- SimpleSC::StopService "laserredis" 0 30
- SimpleSC::RemoveService "laserredis"
- ${EndIf}
- SimpleSC::ExistsService "checkLaserProcess"
- Pop $0
- ${If} $0 == 0
- SimpleSC::StopService "checkLaserProcess" 0 30
- SimpleSC::RemoveService "checkLaserProcess"
- ${EndIf}
- FunctionEnd
- Function installService
- ${StrRep} $0 '$INSTDIR\mysql' '\' '\\'
- StrCpy $basedir $0
- ${StrRep} $0 '$INSTDIR\mysql\data' '\' '\\'
- StrCpy $datadir $0
- ${StrRep} $0 '$INSTDIR\mysql\logs.log' '\' '\\'
- StrCpy $logError $0
- WriteINIStr $INSTDIR\mysql\my.ini mysqld port 3307
- WriteINIStr $INSTDIR\mysql\my.ini mysqld basedir $basedir
- WriteINIStr $INSTDIR\mysql\my.ini mysqld datadir $datadir
- WriteINIStr $INSTDIR\mysql\my.ini mysqld log-error $logError
- WriteINIStr $INSTDIR\mysql\my.ini mysqld max_connections 1000
- WriteINIStr $INSTDIR\mysql\my.ini mysqld max_connect_errors 10
- WriteINIStr $INSTDIR\mysql\my.ini mysqld character-set-server utf8mb4
- WriteINIStr $INSTDIR\mysql\my.ini mysqld default-storage-engine INNODB
- WriteINIStr $INSTDIR\mysql\my.ini mysqld default_authentication_plugin mysql_native_password
- WriteINIStr $INSTDIR\mysql\my.ini mysqld local_infile ON
- WriteINIStr $INSTDIR\mysql\my.ini mysql default-character-set utf8mb4
- WriteINIStr $INSTDIR\mysql\my.ini mysql local_infile ON
- WriteINIStr $INSTDIR\mysql\my.ini client port 3307
- WriteINIStr $INSTDIR\mysql\my.ini client default-character-set utf8mb4
- Sleep 2000
- SetOutPath "$INSTDIR\mysql\bin"
- nsExec::ExecToStack '"cmd.exe" /c mysqld.exe --initialize-insecure --lower-case-table-names=1'
- nsExec::ExecToStack '"cmd.exe" /c mysqld.exe --install lasermysql'
- nsExec::ExecToStack '"cmd.exe" /c powercfg.exe /hibernate off '
- SimpleSC::StartService "lasermysql" "" 30
- SetOutPath "$INSTDIR\redis"
- nsExec::ExecToStack '"cmd.exe" /c redis-server.exe --service-install "$INSTDIR\redis\redis.windows.conf" --service-name laserredis --loglevel verbose'
- SimpleSC::StartService "laserredis" "" 30
- nsExec::ExecToStack '"cmd.exe" /c sc config laserredis start=auto'
- SimpleSC::RestartService "laserredis" "" 30
- Sleep 2000
- SetOutPath "$INSTDIR\mongodb"
- ${StrRep} $0 '$INSTDIR\mongodb\db' '\' '\\'
- StrCpy $dbpath $0
- ${StrRep} $0 '$INSTDIR\mongodb\logs\mongo.log' '\' '\\'
- StrCpy $logpath $0
- FileOpen $0 $INSTDIR\mongodb\mongo.conf w
- IfErrors done
- FileWrite $0 'port=29031$\n'
- FileWrite $0 'dbpath=$dbpath$\n'
- FileWrite $0 'logpath=$logpath$\n'
- FileWrite $0 'logappend=true$\n'
- FileWrite $0 'maxConns=1000$\n'
- FileClose $0
- done:
- nsExec::ExecToStack '"cmd.exe" /c sc create lasermongodb binpath= "$INSTDIR\mongodb\bin\mongod.exe --config $INSTDIR\mongodb\mongo.conf --service" start= auto'
- SimpleSC::StartService "lasermongodb" "" 30
- Sleep 2000
- ; IfFileExists "$INSTDIR\USER_DATA\static\*.*" 0 static_not_found
- ; CopyFiles /SILENT $INSTDIR\USER_DATA\static\*.* $INSTDIR\4DKK_PROGRAM_STATIC
- ; RMDir /r "$INSTDIR\USER_DATA\static"
- ; goto static_end_of
- ; static_not_found:
- ; goto static_end_of
- ; static_end_of:
- ; IfFileExists "$INSTDIR\USER_DATA\pro\*.*" 0 pro_not_found
- ; CopyFiles /SILENT $INSTDIR\USER_DATA\pro\*.* $INSTDIR\4DKK_PROGRAM_DATA
- ; RMDir /r "$INSTDIR\USER_DATA\pro"
- ; goto pro_end_of
- ; pro_not_found:
- ; goto pro_end_of
- ; pro_end_of:
- Sleep 2000
- ;
- ${StrRep} $0 '$INSTDIR\4DKK_PROGRAM_DATA\' '\' '\\'
- StrCpy $buildModelPath $0
- ${StrRep} $0 '$INSTDIR\4DKK_PROGRAM_STATIC\' '\' '\\'
- StrCpy $profilePath $0
- ${StrRep} $0 '$INSTDIR\CGAII' '\' '\\'
- StrCpy $buildCallPath $0
- ${StrRep} $0 '$INSTDIR\bin\resources\static' '\' '\\'
- StrCpy $binPath $0
- ${StrRep} $0 '$INSTDIR\jdk1.8\bin\java.exe' '\' '\\'
- StrCpy $javaPath $0
- nsJSON::Set /file $INSTDIR\bin\resources\static\setting.json
- nsJSON::Set /value `{}`
- nsJSON::Set `sceneConfig` /value `"config.json"`
- nsJSON::Set `sceheKey` /value `"id"`
- nsJSON::Set `sceneBundle` /value `"./build.zip"`
- nsJSON::Set `sceneBundleDir` /value `"capture"`
- nsJSON::Set `buildModelPath` /value `"$buildModelPath"`
- nsJSON::Set `javaPort` /value `9000`
- nsJSON::Set `javaPath` /value `"$javaPath"`
- nsJSON::Set `profilePath` /value `"$profilePath"`
- nsJSON::Set `buildCallPath` /value `"$buildCallPath"`
- nsJSON::Set `binPath` /value `"$binPath"`
- nsJSON::Serialize /format /file $INSTDIR\bin\resources\static\setting.json
- nsExec::ExecToStack '"$INSTDIR\tools\service.bat" $INSTDIR '
- nsExec::ExecToStack '"$INSTDIR\tools\update.bat" $INSTDIR '
- ; FileOpen $0 $INSTDIR\bin\resources\static\4dmega.vmoptions w
- ; IfErrors done
- ; FileWrite $0 '-DBIN_PATH=$INSTDIR\bin\resources\static$\n'
- ; FileWrite $0 '-DPROFILE_PATH=$INSTDIR\4DKK_PROGRAM_STATIC\$\n'
- ; FileWrite $0 '-DBUILD_MODEL_PATH=$INSTDIR\4DKK_PROGRAM_DATA\$\n'
- ; FileWrite $0 '-DBUILD_CALL_PATH=$INSTDIR\CGAII\$\n'
- ; FileWrite $0 '-Dspring.profiles.active=standAloneProd$\n'
- ; FileWrite $0 '-Dserver.port=9000$\n'
- ; FileClose $0
- ; done:
- nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\tools\MonitorPid.exe install '
- functionend
- Function OnFinished
- #MessageBox MB_YESNO|MB_ICONQUESTION "需要重启系统才能完成安装" IDNO +2
- #Reboot
- #Exec "$INSTDIR${EXE_NAME}"
- Call OnExitDUISetup
- FunctionEnd
- Function OnBtnSelectDir
- nsNiuniuSkin::SelectInstallDirEx $hInstallDlg "请选择安装路径"
- Pop $0
- ${Unless} "$0" == ""
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" $0
- ${EndUnless}
- FunctionEnd
- Function StepHeightSizeAsc
- ${ForEach} $R0 390 500 + 10
- nsNiuniuSkin::SetWindowSize $hInstallDlg 480 $R0
- Sleep 5
- ${Next}
- FunctionEnd
- Function StepHeightSizeDsc
- ${ForEach} $R0 480 390 - 10
- nsNiuniuSkin::SetWindowSize $hInstallDlg 480 $R0
- Sleep 5
- ${Next}
- FunctionEnd
- Function OnBtnShowMore
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "moreconfiginfo" "visible" "true"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "visible" "true"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "visible" "false"
- GetFunctionAddress $0 StepHeightSizeAsc
- BgWorker::CallAndWait
-
- nsNiuniuSkin::SetWindowSize $hInstallDlg 480 500
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "true"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "true"
- FunctionEnd
- Function OnBtnHideMore
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "moreconfiginfo" "visible" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "visible" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "visible" "true"
- GetFunctionAddress $0 StepHeightSizeDsc
- BgWorker::CallAndWait
- nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "true"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "true"
- FunctionEnd
- Function OnBtnShowConfig
- ;nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_CONFIG}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "visible" "false"
- FunctionEnd
- Function OnBtnDirPre
-
- StrCpy $R8 "确定要取消四维深时本地版安装吗?"
- StrCpy $R7 "0"
- Call ShowMsgBox
- ;nsNiuniuSkin::PrePage "wizardTab"
- FunctionEnd
- Function un.BtnDirPre
-
- StrCpy $R8 "确定要取消四维深时本地版卸载吗?"
- StrCpy $R7 "0"
- Call un.ShowMsgBox
- ;nsNiuniuSkin::PrePage "wizardTab"
- FunctionEnd
- Function un.ShowMsgBox
- nsNiuniuSkin::InitSkinSubPage "msgBox.xml" "btnOK" "btnCancel,btnClose"
- Pop $hInstallSubDlg
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblTitle" "text" "提示"
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblMsg" "text" "$R8"
- ${If} "$R7" == "1"
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "hlCancel" "visible" "true"
- ${EndIf}
-
- nsNiuniuSkin::ShowSkinSubPage 0
- FunctionEnd
- Function un.ExitDUISetup
- nsNiuniuSkin::ExitDUISetup
- FunctionEnd
- Function un.OnBtnMin
- SendMessage $hInstallDlg ${WM_SYSCOMMAND} 0xF020 0
- FunctionEnd
- Section "un.silentInstallSec" SEC02
- #MessageBox MB_OK|MB_ICONINFORMATION "Test silent install. you can add your silent uninstall code here."
- SectionEnd
- Function un.onUninstall
- nsProcess::_FindProcess "${EXE_NAME_EXT}"
- Pop $R0
-
- ${If} $R0 == 0
- StrCpy $R8 "${PRODUCT_NAME} 正在运行,请退出后重试!"
- StrCpy $R7 "0"
- Call un.ShowMsgBox
- goto InstallAbort
- ${EndIf}
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkbox_userdata" "selected"
- Pop $0
- StrCpy $sReserveData $0
- ${If} $sReserveData == 1
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" "正在准备卸载..."
- CreateDirectory $INSTDIR\USER_DATA
- ${EndIf}
-
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "false"
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTPROCESSING}
-
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "min" "0"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "max" "100"
- IntOp $UnInstallValue 0 + 1
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" "正在准备卸载..."
- GetFunctionAddress $0 un.OnEnvDownInstall
- BgWorker::CallAndWait
- nsExec::ExecToStack 'cmd.exe /c powercfg.exe /hibernate on '
- GetFunctionAddress $0 un.installService
- BgWorker::CallAndWait
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" "正在卸载..."
- Call un.DeleteShotcutAndInstallInfo
-
- IntOp $UnInstallValue $UnInstallValue + 8
-
- GetFunctionAddress $0 un.RemoveFiles
- BgWorker::CallAndWait
- InstallAbort:
- FunctionEnd
- Function un.RemoveFiles
- ${Locate} "$INSTDIR" "/G=0 /M=*.*" "un.onDeleteFileFound"
-
- StrCpy $InstallState "1"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "true"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "100"
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTFINISH}
- FunctionEnd
- Function un.onDeleteFileFound
- ; $R9 "path\name"
- ; $R8 "path"
- ; $R7 "name"
- ; $R6 "size" ($R6 = "" if directory, $R6 = "0" if file with /S=)
-
-
- ${If} $sReserveData == 0
- Delete "$R9"
- RMDir /r "$R9"
- RMDir "$R9"
- ${EndIf}
- ${If} $sReserveData == 1
- RMDir /r "$R8\bin"
- RMDir /r "$R8\CGAII"
- RMDir /r "$R8\mongodb"
- RMDir /r "$R8\mysql"
- RMDir /r "$R8\redis"
- RMDir /r "$R8\jdk1.8"
- ; RMDir /r "$R8\4DKK_PROGRAM_STATIC"
- ; RMDir /r "$R8\4DKK_PROGRAM_DATA"
- RMDir /r "$R8\tools"
- Delete "$R8\uninst.exe"
- ${EndIf}
- IntOp $UnInstallValue $UnInstallValue + 2
- ${If} $UnInstallValue > 100
- IntOp $UnInstallValue 100 + 0
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "100"
- ${Else}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "$UnInstallValue"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_pos" "text" "$UnInstallValue%"
-
- #Sleep 100
- ${EndIf}
- undelete:
- Push "LocateNext"
- FunctionEnd
- #
- # 以 Unicode 字符串的方式进行判断 (与 NSIS 是 ANSI/Unicode 无关)
- # 但建议 Unicode 版本优先使用此函数。
- #
- Function PathIsDBCS_W
- Exch $R0
- Push $R1
- Push $R2
- Push $R3
- System::Call "*(&w${NSIS_MAX_STRLEN}R0)p.R1"
- StrCpy $R0 0
- StrCpy $R2 $R1
- lbl_loop:
- # Unicode 版取 2 个字节长度的字符,字符串遇到 0 字符表示结束了。
- System::Call "*$R2(&i2.R3)"
- IntCmp $R3 0 lbl_done
- # Unicode 字符直接判断字符值,大于 128 的我们就视为非英文字符。
- IntCmp $R3 128 0 lbl_skip
- IntOp $R0 $R0 !
- Goto lbl_done
- lbl_skip:
- # 如果用 NSIS 3.x 这里可以用 IntPtrOp 代替。
- IntOp $R2 $R2 + 2
- Goto lbl_loop
- lbl_done:
- System::Free $R1
- Pop $R3
- Pop $R2
- Pop $R1
- Exch $R0
- FunctionEnd
- #
- # 以 ANSI 字符串的方式进行判断 (与 NSIS 是 ANSI/Unicode 无关)
- # 但建议 ANSI 版本优先使用此函数。
- #
- Function PathIsDBCS_A
- Exch $R0
- Push $R1
- Push $R2
- Push $R3
- Push $R4
- System::Call "*(&m${NSIS_MAX_STRLEN}R0)p.R1"
- StrCpy $R0 0
- StrCpy $R2 $R1
- lbl_loop:
- # ANSI 版取 1 个字节长度的字符,字符串遇到 0 字符表示结束了。
- System::Call "*$R2(&i1.R3)"
- IntCmp $R3 0 lbl_done
- # ANSI 字符用 IsDBCSLeadByte 判断是否双字节字符的前导字节。
- System::Call "kernel32::IsDBCSLeadByte(iR3)i.R4"
- IntCmp $R4 0 lbl_skip
- IntOp $R0 $R0 !
- Goto lbl_done
- lbl_skip:
- # 用 CharNextA 得到下一个字符的地址 (可正确处理双字节字符)。
- System::Call "user32::CharNextA(pR2)p.R2"
- Goto lbl_loop
- lbl_done:
- Pop $R4
- Pop $R3
- Pop $R2
- Pop $R1
- Exch $R0
- FunctionEnd
- #
- # 当选择的安装路径变更时,路径为空或包含双字节字符 (不限于简体中文),都不允许继续。
- # 路径为空时,NSIS 会自行判断。
- #
- # 此示例未判断是否包含空格。如有需要,请与示例一配合使用。
- #
- Function onVerifyInstDir
- # 检查安装路径是否包含双字节字符 (不限于简体中文)。
- StrCpy $0 $INSTDIR
- StrLen $1 $0
- # 这里也可以换成 PathIsDBCS_A 以测试效果。
- ${If} $1 == 0
- Push 2
- ${Else}
- Push $INSTDIR
- Call PathIsDBCS_A
- Pop $R0
- Push $R0
- ${endif}
- lbl_done:
- FunctionEnd
- Function isEmptyDir
- # Stack -> # Stack: <directory>
- Exch $0 # Stack: $0
- Push $1 # Stack: $1, $0
- FindFirst $0 $1 "$0\*.*"
- strcmp $1 "." 0 _notempty
- FindNext $0 $1
- strcmp $1 ".." 0 _notempty
- ClearErrors
- FindNext $0 $1
- IfErrors 0 _notempty
- FindClose $0
- Pop $1 # Stack: $0
- StrCpy $0 1
- Exch $0 # Stack: 1 (true)
- goto _end
- _notempty:
- FindClose $0
- ClearErrors
- Pop $1 # Stack: $0
- StrCpy $0 0
- Exch $0 # Stack: 0 (false)
- _end:
- FunctionEnd
- Function un.isEmptyDir
- # Stack -> # Stack: <directory>
- Exch $0 # Stack: $0
- Push $1 # Stack: $1, $0
- FindFirst $0 $1 "$0\*.*"
- strcmp $1 "." 0 _notempty
- FindNext $0 $1
- strcmp $1 ".." 0 _notempty
- ClearErrors
- FindNext $0 $1
- IfErrors 0 _notempty
- FindClose $0
- Pop $1 # Stack: $0
- StrCpy $0 1
- Exch $0 # Stack: 1 (true)
- goto _end
- _notempty:
- FindClose $0
- ClearErrors
- Pop $1 # Stack: $0
- StrCpy $0 0
- Exch $0 # Stack: 0 (false)
- _end:
- FunctionEnd
|