使用nsis将jar复制到新文件夹

问题描述:

使用以下脚本创建的安装程序将其包含的所有文件复制到单个文件夹,我想在Calculator文件夹中创建一个文件夹lib,并将所有jar文件复制到lib文件夹,应用程序可以找到我在类路径中指定的罐子。我怎样才能使用NSIS设置环境变量。请帮助,因为我是NSIS的新手。使用nsis将jar复制到新文件夹

; 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 
+0

如果应用程序。是一款桌面应用程序。 (使用GUI),然后[Java Web Start](http://*.com/tags/java-web-start/info)可以1)将罐子放在正确的位置。 2)根据需要自动更新它们。 3)设置属性和环境变量。 - 为什么计算器需要设置环境变量? – 2013-03-19 08:14:36

你可以做到这一点通过与/r标志递归添加文件:

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

这将保留目录结构,罐子将被安装在一个lib子目录。

+0

注意'/ r'标志的特殊行为:如果你给出一个获取文件的模式(比如'* .pl'),你可以从这个例子中的'IMS'目录的子目录中获得其他.pl文件。它在手册中以一些神秘的方式进行了解释。 – Seki 2013-03-19 10:00:30