以下のスクリプトを使用して作成した私のセットアップは、それに含まれるすべてのファイルを 1 つlib
のフォルダーにコピーします。フォルダーにフォルダーを作成し、Calculator
すべての jar ファイルを lib フォルダーにコピーして、アプリケーションがクラスパスで指定した jar を見つけられるようにします。 . また、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