【问题标题】:Copying jar's to a new folder using nsis使用 nsis 将 jar 复制到新文件夹
【发布时间】:2013-03-19 08:11:36
【问题描述】:

我使用以下脚本创建的设置将它包含的所有文件复制到一个文件夹中,我想在 Calculator 文件夹中创建一个文件夹 lib 并将所有 jar 文件复制到 lib 文件夹中,以便我的应用程序可以找到我在类路径中指定的 jars。以及如何使用 NSIS 设置环境变量。请帮忙,因为我是 NSIS 的新手。

; Name of our application
Name "Calculator"

; The file to write
OutFile "Calculatorv1.0_Setup.exe"

; Set the default Installation Directory
InstallDir "$PROGRAMFILES\Calculator"

; Set the text which prompts the user to enter the installation directory
DirText "Please choose a directory to which you'd like to install this application."

; ----------------------------------------------------------------------------------
; *************************** SECTION FOR INSTALLING *******************************
; ----------------------------------------------------------------------------------

Section "" ; A "useful" name is not needed as we are not installing separate components

; Set output path to the installation directory. Also sets the working
; directory for shortcuts
SetOutPath $INSTDIR\

File G:\IMS\dist\Calculator.exe
File G:\IMS\dist\lib\*.jar

File a.nsi

WriteUninstaller $INSTDIR\Uninstall.exe

; ///////////////// CREATE SHORT CUTS //////////////////////////////////////

CreateDirectory "$SMPROGRAMS\Calculator"


CreateShortCut "$SMPROGRAMS\Calculator\Run Calculator.lnk" "$SYSDIR\javaw.exe" "NSISExampleApplication1"


CreateShortCut "$SMPROGRAMS\Calculator\Uninstall Example Application 1.lnk" "$INSTDIR\Uninstall.exe"

; ///////////////// END CREATING SHORTCUTS //////////////////////////////////

; //////// CREATE REGISTRY KEYS FOR ADD/REMOVE PROGRAMS IN CONTROL PANEL /////////

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Calculator" "DisplayName"\
"Calculator (remove only)"

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Calculator" "UninstallString" \
"$INSTDIR\Uninstall.exe"

; //////////////////////// END CREATING REGISTRY KEYS ////////////////////////////

MessageBox MB_OK "Installation was successful."

SectionEnd

; ----------------------------------------------------------------------------------
; ************************** SECTION FOR UNINSTALLING ******************************
; ----------------------------------------------------------------------------------

Section "Uninstall"
; remove all the files and folders
Delete $INSTDIR\Uninstall.exe ; delete self
Delete $INSTDIR\Calculator.exe
Delete $INSTDIR\a.nsi

RMDir $INSTDIR

; now remove all the startmenu links
Delete "$SMPROGRAMS\Calculator\Run Calculator.lnk"
Delete "$SMPROGRAMS\Calculator\Uninstall Calculator.lnk"
RMDIR "$SMPROGRAMS\Calculator"

; Now delete registry keys
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Calculator"
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Calculator"
SectionEnd

【问题讨论】:

  • 如果应用程序。是一个桌面应用程序。 (使用 GUI)然后Java Web Start 可以 1)将罐子放在正确的位置。 2)根据需要自动更新它们。 3) 设置属性和环境变量。 -- 为什么计算器需要设置环境变量?

标签: java deployment environment-variables nsis


【解决方案1】:

您可以通过使用/r 标志递归地添加文件来做到这一点:

File /r "G:\IMS\dist\*"

这将保留目录结构,并且 jar 将安装在 lib 子目录中。

【讨论】:

  • 当心/r 标志的特殊行为:如果您提供获取文件的模式(如*.pl),您可以从IMS 的子目录中获取其他.pl 文件本例中的目录。它在手册中以某种神秘的方式进行了解释。
猜你喜欢
  • 2013-08-19
  • 1970-01-01
  • 2014-06-21
  • 1970-01-01
  • 2014-12-03
  • 2010-10-28
  • 1970-01-01
  • 2012-01-22
  • 1970-01-01
相关资源
最近更新 更多