我做的NSIS程序

outfile "LoadMaster_Enterprise_Multilanguage_Setup.exe"
;!include "D:\Program Files\NSIS\Contrib\Modern UI\system.nsh"
!include "${NSISDIR}\Include\LogicLib.nsh"
!define PRODUCT_NAME "LoadMaster"
!define PRODUCT_VERSION "4.0"
!define PRODUCT_WEB_SITE "http://www.zhuangxiang.com"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define MUI_WELCOMEFINISHPAGE_BITMAP "F:\tub\pic.bmp"
!include "MUI2.nsh"
!include WordFunc.nsh

 

SetCompressor lzma
XPStyle on
!insertmacro MUI_PAGE_WELCOME

!insertmacro MUI_PAGE_LICENSE "$(ln)"

!insertmacro MUI_PAGE_DIRECTORY

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_LANGUAGE "TradChinese"


icon f:\tub\LD.ico
uninstallicon "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"


InstallDir "$programfiles\LoadMaster4.0"

BrandingText    "http://www.zhuangxiang.com/"

Name $(Name)
LangString Name ${LANG_ENGLISH} "LoadMaster_Enterprise"
LangString Name ${LANG_SIMPCHINESE}  "装箱大师企业版"
LangString name 1028 "裝箱大師企業版"
ShowInstDetails show
ShowUnInstDetails show

Section "MainSection"
setoutpath  $INSTDIR
;file /r  "f:\abc\*.*"
file /r  "f:\workspace2\*.*"

createdirectory   $SYSDIR\vcredist_x86
setoutpath  $SYSDIR\vcredist_x86
ExecWait '"$INSTDIR\vcredist_x86.exe"'
delete "$instdir\vcredist_x86.exe"
SectionEnd

function .onInit

System::Call "Kernel32::GetSystemDefaultLangID(v ..) i .s"
  Pop $3
  ${if} $3 = 2052
    call cn
  ${endif}
  ${if} $3 = 1033
  call en
   ${endif}
  ${if} $3 = 1028
  call tn
  ${endif}
  
  Push $0
   Push $1
System::Call "mscoree::GetCORVersion(w .r0, i ${NSIS_MAX_STRLEN}, *i) i .r1 ?u"
${if} $language = 2052
StrCmp $0 "" 0 +4
Messagebox MB_OK "安装程序检测到您计算机上没有安装.Net Framework 2.0,您必须先安装.Net Framework 2.0 或以上版本,才能安装运行本软件! "
ExecShell "open" "http://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=zh-cn"
abort

${endif}
${if} $language = 1028
strcmp $0 "" 0 +4
Messagebox MB_OK "安裝程序檢測到您計算機上沒有安裝.Net Framework 2.0,您必須先安裝.Net Framework 2.0 或以上版本,才能安裝運行本軟件! "
ExecShell "open" "http://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=zh-cn"
abort
${endif}
${if} $language = 1033
strcmp $0 "" 0 +4
Messagebox MB_OK "Detecting that you have not installed .Net Framework 2.0 on your computer, you must first install .Net Framework 2.0 or above, in order to run the installation of this software!"
ExecShell "open" "http://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=zh-cn"
abort
${endif}

StrCpy $R0 $0 "" 1
intop $8 $r0 - 2
${if} $8 < 0
${if} $3 = 2052
Messagebox MB_ok "安装程序检测到您计算机上的.Net Framework 版本低于2.0,您的版本是$r0 ,您必须先安装.Net Framework 2.0 或以上版本,才能安装运行本软件!"
ExecShell "open" "http://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=zh-cn"
abort
${endif}
${if} $3 = 1028
Messagebox MB_ok "安裝程序檢測到您計算機上的.Net Framework 版本低於2.0,您的版本是$r0 ,您必須先安裝.Net Framework 2.0 或以上版本,才能安裝運行本軟件!"
ExecShell "open" "http://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=zh-cn"
abort
${endif}
${if} $3 = 1033
Messagebox MB_ok "Detecting your computer .Net Framework version lower than 2.0, your version is $r0, you must first install .Net Framework 2.0 or above, in order to run the installation of this software!"
ExecShell "open" "http://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=zh-cn"
abort
${endif}
${endif}
FunctionEnd

function cn

  Push ""
  Push ${LANG_ENGLISH}
  push "English"
  push ${LANG_TRADCHINESE}
  Push "繁體中文"
  Push ${LANG_SIMPCHINESE}
  Push "简体中文"
  Push A
  LangDLL::LangDialog " 安装语言"   "请选择安装语言与软件界面"
  Pop $LANGUAGE
  StrCmp $LANGUAGE "cancel" 0 +2
    Abort

functionend
function en
  Push ""
  Push ${LANG_ENGLISH}
  push "English"
  push ${LANG_TRADCHINESE}
  Push "繁體中文"
  Push ${LANG_SIMPCHINESE}
  Push "简体中文"
  Push A
  LangDLL::LangDialog "Installer Language" "Please select a language and software interface language "
  Pop $LANGUAGE
  StrCmp $LANGUAGE "cancel" 0 +2
    Abort

functionend
function tn
  Push ""
  Push ${LANG_ENGLISH}
  push "English"
  push ${LANG_TRADCHINESE}
  Push "繁體中文"
  Push ${LANG_SIMPCHINESE}
  Push "简体中文"
  Push A
  LangDLL::LangDialog " 安裝語言"   "請選擇安裝語言與軟件界面"
  Pop $LANGUAGE
  strcpy $0 $language
   StrCmp $LANGUAGE "cancel" 0 +2
    Abort

functionend


section writeregedit
setoutpath $INSTDIR
 WriteRegStr HKLM   software\LoadMaster version "${PRODUCT_VERSION} "
 writeregstr HKLM   software\LoadMaster path "$INSTDIR"
 writeregstr HKLM   software\LoadMaster language "$LANGUAGE"
  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\LoadMasterMain.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
sectionend

LicenseLangString ln ${LANG_ENGLISH} f:\enlicense2.txt
LicenseLangString ln ${LANG_TRADCHINESE} f:\tnlicense2.txt
LicenseLangString ln ${LANG_SIMPCHINESE} f:\cnlicense2.txt
  

Section -AdditionalIcons
${switch} $language
${Case}  1033
  SetOutPath "$INSTDIR"
  file "f:\en\LoadMasterMain.exe.config"
  WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
  CreateDirectory "$SMPROGRAMS\LoadMaster"
  createshortcut "$SMPROGRAMS\LoadMaster\LoadMaster4.0.lnk" "$instdir\LoadMasterMain.exe"
  CreateShortCut "$SMPROGRAMS\LoadMaster\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
  createshortcut "$SMPROGRAMS\LoadMaster\Manual.lnk" "$instdir\Manual.chm"
  CreateShortCut "$SMPROGRAMS\LoadMaster\Uninstall.lnk" "$INSTDIR\uninst.exe"
  createshortcut "$desktop\LoadMaster4.0.lnk" "$instdir\LoadMasterMain.exe"
  ${Break}
${Case} 2052
  SetOutPath "$INSTDIR"
  file "f:\cn\LoadMasterMain.exe.config"
  WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
  CreateDirectory "$SMPROGRAMS\装箱大师企业版"
  CreateShortCut "$SMPROGRAMS\装箱大师企业版\装箱大师官方网站.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
  CreateShortCut "$SMPROGRAMS\装箱大师企业版\装箱大师企业版卸载.lnk" "$INSTDIR\uninst.exe"
  CreateShortCut "$SMPROGRAMS\装箱大师企业版\装箱大师企业版帮助文档.lnk" "$INSTDIR\Manual.chm"
  CreateShortCut "$SMPROGRAMS\装箱大师企业版\装箱大师企业版4.0.lnk" "$INSTDIR\LoadMasterMain.exe"
  CreateShortCut "$DESKTOP\装箱大师企业版4.0.lnk" "$INSTDIR\LoadMasterMain.exe"
  ${Break}
${Case} 1028
 SetOutPath "$INSTDIR"
 file "f:\tn\LoadMasterMain.exe.config"
  WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
  CreateDirectory "$SMPROGRAMS\裝箱大師企業版"
  CreateShortCut "$SMPROGRAMS\裝箱大師企業版\裝箱大師官方網站.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
  CreateShortCut "$SMPROGRAMS\裝箱大師企業版\裝箱大師企業版卸載.lnk" "$INSTDIR\uninst.exe"
  CreateShortCut "$SMPROGRAMS\裝箱大師企業版\裝箱大師企業版幫助文檔.lnk" "$INSTDIR\Manual.chm"
  createshortcut "$smprograms\裝箱大師企業版\裝箱大師企業版4.0.lnk" "$instdir\LoadMasterMain.exe"
  createshortcut "$desktop\裝箱大師企業版4.0.lnk" "$instdir\LoadMasterMain.exe"
${Break}

${EndSwitch}
SectionEnd


section woriteunistallreg
  writeuninstaller  "$instdir\uninst.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}" "DisplayVersion" "${PRODUCT_VERSION}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
sectionend


section uninstall
 deleteregkey  ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
 deleteregkey  hklm  software\LoadMaster\path
 deleteregkey HKLM   software\LoadMaster\version
 
; messagebox MB_OK "$5"

${if} $5 = 2052

  Delete "$INSTDIR\${PRODUCT_NAME}.url"
  Delete "$INSTDIR\uninst.exe"
  Delete "$INSTDIR\templet.zh-CHN.xls"
  Delete "$INSTDIR\templet.zh-CN.xls"
  Delete "$INSTDIR\templet.xls"
  Delete "$INSTDIR\resources.cfg"
  Delete "$INSTDIR\Manual.chm"
  Delete "$INSTDIR\Mogre.dll"
  Delete "$INSTDIR\MOIS.dll"
  Delete "$INSTDIR\Ogre.log"
  Delete "$INSTDIR\OgreMain.dll"
  Delete "$INSTDIR\OIS.dll"
  Delete "$INSTDIR\plugins.cfg"
  delete "$instdir\Plugin_OctreeSceneManager.dll"
  Delete "$INSTDIR\RenderSystem_Direct3D9.dll"
  Delete "$INSTDIR\RenderSystem_GL.dll"
  delete "$instdir\D3DX9_39.dll"
  delete "$instdir\LoadMasterUIControlLibrary.dll"
  delete "$instdir\ToolsForDataTransfer.exe"
  delete "$instdir\装箱大师新增功能.txt"
  Delete "$INSTDIR\Csla.dll"
  Delete "$INSTDIR\database.mdb"
  Delete "$INSTDIR\GEARS.ico"
  Delete "$INSTDIR\HID.exe"
  Delete "$INSTDIR\LoadMasterMain.exe"
  Delete "$INSTDIR\LoadMasterMain.exe.config"
  Delete "$INSTDIR\cg.dll"
  Delete "$INSTDIR\csgl.dll"
  Delete "$INSTDIR\csgl.native.dll"
  RMDir /r  "$INSTDIR\Media\*.*"
  RMDir /r  "$INSTDIR\zh-CN\*.*"
  RMDir /r  "$INSTDIR\zh-HK\*.*"
 
  Delete "$SMPROGRAMS\装箱大师企业版\装箱大师企业版卸载.lnk"
  Delete "$SMPROGRAMS\装箱大师企业版\装箱大师官方网站.lnk"
  Delete "$SMPROGRAMS\装箱大师企业版\装箱大师企业版帮助文档.lnk"
  Delete "$DESKTOP\装箱大师企业版4.0.lnk"
  Delete "$SMPROGRAMS\装箱大师企业版\装箱大师企业版4.0.lnk"
  RMDir  "$INSTDIR"
  RMDir "$SMPROGRAMS\装箱大师企业版"
 SetAutoClose true
${endif}

${if} $5 = 1033
  Delete "$INSTDIR\${PRODUCT_NAME}.url"
  Delete "$INSTDIR\uninst.exe"
  Delete "$INSTDIR\templet.zh-CHN.xls"
  Delete "$INSTDIR\templet.zh-CN.xls"
  Delete "$INSTDIR\templet.xls"
  Delete "$INSTDIR\resources.cfg"
  Delete "$INSTDIR\Manual.chm"
  Delete "$INSTDIR\Mogre.dll"
  Delete "$INSTDIR\MOIS.dll"
  Delete "$INSTDIR\Ogre.log"
  Delete "$INSTDIR\OgreMain.dll"
  Delete "$INSTDIR\OIS.dll"
  Delete "$INSTDIR\plugins.cfg"
  delete "$instdir\Plugin_OctreeSceneManager.dll"
  Delete "$INSTDIR\RenderSystem_Direct3D9.dll"
  Delete "$INSTDIR\RenderSystem_GL.dll"
  delete "$instdir\D3DX9_39.dll"
  delete "$instdir\LoadMasterUIControlLibrary.dll"
  delete "$instdir\ToolsForDataTransfer.exe"
  delete "$instdir\装箱大师新增功能.txt"
  Delete "$INSTDIR\Csla.dll"
  Delete "$INSTDIR\database.mdb"
  Delete "$INSTDIR\GEARS.ico"
  Delete "$INSTDIR\HID.exe"
  Delete "$INSTDIR\LoadMasterMain.exe"
  Delete "$INSTDIR\LoadMasterMain.exe.config"
  Delete "$INSTDIR\cg.dll"
  Delete "$INSTDIR\csgl.dll"
  Delete "$INSTDIR\csgl.native.dll"
  RMDir /r  "$INSTDIR\Media\*.*"
  RMDir /r  "$INSTDIR\zh-CN\*.*"
  RMDir /r  "$INSTDIR\zh-HK\*.*"
 

Delete "$SMPROGRAMS\LoadMaster\Website.lnk"
Delete "$SMPROGRAMS\LoadMaster\Uninstall.lnk"
Delete "$SMPROGRAMS\LoadMaster\Manual.lnk"
delete "$smprograms\LoadMaster\LoadMaster4.0.lnk"
RMDir  "$INSTDIR"
RMDir "$SMPROGRAMS\LoadMaster"
delete "$desktop\LoadMaster4.0.lnk"
SetAutoClose true
${endif}

${if} $5 = 1028
  Delete "$INSTDIR\${PRODUCT_NAME}.url"
  Delete "$INSTDIR\uninst.exe"
  Delete "$INSTDIR\templet.zh-CHN.xls"
  Delete "$INSTDIR\templet.zh-CN.xls"
  Delete "$INSTDIR\templet.xls"
  Delete "$INSTDIR\resources.cfg"
  Delete "$INSTDIR\Manual.chm"
  Delete "$INSTDIR\Mogre.dll"
  Delete "$INSTDIR\MOIS.dll"
  Delete "$INSTDIR\Ogre.log"
  Delete "$INSTDIR\OgreMain.dll"
  Delete "$INSTDIR\OIS.dll"
  Delete "$INSTDIR\plugins.cfg"
  delete "$instdir\Plugin_OctreeSceneManager.dll"
  Delete "$INSTDIR\RenderSystem_Direct3D9.dll"
  Delete "$INSTDIR\RenderSystem_GL.dll"
  delete "$instdir\D3DX9_39.dll"
  delete "$instdir\LoadMasterUIControlLibrary.dll"
  delete "$instdir\ToolsForDataTransfer.exe"
  delete "$instdir\装箱大师新增功能.txt"
  Delete "$INSTDIR\Csla.dll"
  Delete "$INSTDIR\database.mdb"
  Delete "$INSTDIR\GEARS.ico"
  Delete "$INSTDIR\HID.exe"
  Delete "$INSTDIR\LoadMasterMain.exe"
  Delete "$INSTDIR\LoadMasterMain.exe.config"
  Delete "$INSTDIR\cg.dll"
  Delete "$INSTDIR\csgl.dll"
  Delete "$INSTDIR\csgl.native.dll"
  RMDir /r  "$INSTDIR\Media\*.*"
  RMDir /r  "$INSTDIR\zh-CN\*.*"
  RMDir /r  "$INSTDIR\zh-HK\*.*"
 
 
  Delete "$SMPROGRAMS\裝箱大師企業版\裝箱大師官方網站.lnk"
  Delete "$SMPROGRAMS\裝箱大師企業版\裝箱大師企業版幫助文檔.lnk"
  delete "$smprograms\裝箱大師企業版\裝箱大師企業版4.0.lnk"
  Delete "$SMPROGRAMS\裝箱大師企業版\裝箱大師企業版卸載.lnk"
  delete  "$desktop\裝箱大師企業版4.0.lnk"
  RMDir  "$INSTDIR"
  RMDir  "$SMPROGRAMS\裝箱大師企業版"

SetAutoClose true
${endif}
sectionend

 

Function un.onInit

ReadRegStr $5 HKLM  software\LoadMaster "language"
${if} $5 = 2052
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "您确实要完全移除 装箱大师企业版 ,及其所有的组件?" IDYES goo
    Abort
${endif}
${if} $5 = 1028
  messagebox MB_ICONQUESTION|mb_yesno|MB_DEFBUTTON2 "您確實要完全移除 裝箱大師企業版 ,及其所有的組件?" IDYES goo
  abort
${endif}
${if} $5 = 1033
  messagebox MB_ICONQUESTION|mb_yesno|MB_DEFBUTTON2 "Are you sure you want to completely remove the software, and all its components ?" IDYES goo
  abort
  goo:
 
${endif}
FunctionEnd

Function un.onUninstSuccess
  HideWindow
  ${if} $5 = 2052
  MessageBox MB_ICONINFORMATION|MB_OK "装箱大师企业版 已成功地从您的计算机移除。"
  ${endif}
  ${if} $5 = 1028
  messagebox MB_ICONINFORMATION|MB_OK "裝箱大師企業版 已成功地從您的計算機移除。"
  ${endif}
  ${if} $5 = 1033
  messagebox MB_ICONINFORMATION|MB_OK " The software have been successfully removed"
  ${endif}
 
FunctionEnd


 

你可能感兴趣的:(程序)