cannot open fat jar from a desktop shortcut - nsis

the fat jar opens fine in the location i specified but it wont open when i call it through a desktop shortcut. Although if I right click on the icon and say open file location, it opens the correct file.
SetOutPath $INSTDIR
SetOverwrite on
File C:\jitconsole\JITConsole\jitconsole.jar
SetOutPath $INSTDIR\images
File C:\jitconsole\JITConsole\images\*
SetOutPath $INSTDIR\lib
File C:\jitconsole\JITConsole\lib\*
SetOutPath $DESKTOP
CreateShortcut $DESKTOP\JIT.lnk $INSTDIR\jitconsole.jar "" $INSTDIR\images\JIT_medium.ico
any help would be greatly appreciated
thanks

A .jar could open in any application, on my system it is set to open in WinRar!
You should create a shortcut that executes the correct command line:
CreateDirectory $Desktop ; Make sure desktop exists
SetOutPath $Instdir ; Sets the .lnk working directory
CreateShortcut "$DESKTOP\JIT.lnk" "c:\path\to\java.exe" "$INSTDIR\jitconsole.jar" "$INSTDIR\images\JIT_medium.ico"
This means you need to figure out the java path in the installer and if the java path changes your shortcut might break. It is probably a better idea to use a java loader app:
CreateDirectory $Desktop ; Make sure desktop exists
CreateShortcut "$DESKTOP\JIT.lnk" "$INSTDIR\MyJavaLoaderForMyApp.exe" "" "$INSTDIR\images\JIT_medium.ico"

Related

How to add directory and sub directories in installer package

I have many files and folders to be added to my installation package. I tried command
File /nonfatal /a /r "C:\Users\test\hdp*"
and
File /nonfatal /a /r "C:\Users\test\hdp\"
but it didn't create the output file(.exe). I also tried with zip file (means created zip file of hdp folder) and add it into package but the same issue i am facing with zip file also.
hdp folder size is 250MB only.
In documentation also no option is mentioned to add folder. Can someone suggest how to add these folder and subfolders to the package?
You should start with Example1.nsi and understand all of its instructions before trying to write a real installer.
OutFile "myinstaller.exe" ; Name of generated installer .exe
InstallDir "$Desktop\MyApp" ; Change this
Page Directory
Page InstFiles
Section
SetOutPath $InstDir
File /r "c:\users\test\myfilestoinstall\*.*" ; Change this
SectionEnd

NSIS: Install a folder based on 32/64 bits

I'm working on a installer script that needs to install one of two folders based on the OS bits. The selection occurs fine so far but for some reason I only see one folder within the resulting installer.
The relevant sections are below:
;Windows 32 or 64 bit version
!include "x64.nsh"
Section "JRE 64 Bit" Section5
SectionIn RO
;Use the right java version
DetailPrint "JRE extraction..."
SetOutPath "$INSTDIR\${APPDIR}\jre"
File /a /r "${SrcDir}\..\..\jre\jre_64\jre\*.*"
DetailPrint "JRE extraction complete!"
SectionEnd
Section "JRE 32 Bit" Section6
SectionIn RO
;Use the right java version
DetailPrint "JRE extraction..."
SetOutPath "$INSTDIR\${APPDIR}\jre"
File /a /r "${SrcDir}\..\..\jre\jre_32\jre\*.*"
DetailPrint "JRE extraction complete!"
SectionEnd
Function .onInit
#Determine the bitness of the OS and enable the correct section
IntOp $0 ${SF_SELECTED} | ${SF_RO}
${If} ${RunningX64}
SectionSetFlags ${Section5} $0
SectionSetFlags ${Section6} ${SECTION_OFF}
${Else}
SectionSetFlags ${Section5} ${SECTION_OFF}
SectionSetFlags ${Section6} $0
${EndIf}
FunctionEnd
Both folders exists as there is no warning. But instead of seeing two folders (jre_64 and jre_32) I just see one jre folder within the installer.
Is this expected behavior? I'm using NSIS 2.51. The resulting instaler can be found here.
You can see the full script here.
I guess it's because of the delta compression, as the two jre directories should have quite similar contents. The structure when viewing using 7-Zip doesn't necessarily represent the internal structure of the installer, which seems to be quite opaque.
I tried to find a tool to "properly" unpack the installer (like innounp for Inno Setup), but without success. This confirms the NSIS installer structure should be really opaque.
Did you do some manual testing to determine if the installer works as expected in both cases?
The path used in File instructions are not stored in the installer (except for the last path component if it is a folder), it is used to find the files on your development system. As you probably know, SetOutPath sets the destination directory and decompilers can only display parts of that path (they cannot resolve custom variables) and you used just "jre" for both the 32-bit and 64-bit folders.
7-zip is not a full decompiler, it only does what is needed to find the destination path names and it does not understand that there are really two different jre folders selected by your if statements.
NSIS will only store identical files once, add SetDatablockOptimize off to the top of your script and your installer will probably double in size.

nsis uninstaller doesn't remove links

I have this issue:
in the installer sections I have this;
Section "Start Menu Shortcuts"
SetShellVarContext current
CreateDirectory "$SMPROGRAMS\myProgram"
CreateShortCut "$SMPROGRAMS\myProgram\myProgram.lnk" "$INSTDIR\myProgram.exe"
CreateShortCut "$SMPROGRAMS\myProgram\Uninstall myProgram.lnk" "$INSTDIR\myProgram-Uninstall.exe"
SectionEnd
Section "Desktop Shortcut"
SetShellVarContext current
CreateShortCut "$DESKTOP\myProgram.lnk" "$INSTDIR\myProgram.exe"
SectionEnd
and it works fine, I have the icon on the desktop and the icon plus the uninstall icon on the start\programs... tree
the uninstaller section is like this:
SetShellVarContext current
Delete "$DESKTOP\myProgram.lnk"
Delete "$SMPROGRAMS\myProgram\myProgram.lnk"
Delete "$SMPROGRAMS\myProgram\Uninstall myProgram.lnk"
RMDir "$SMPROGRAMS\myProgram"
and the desktop link was deleted, but the other folder with the links not..
any ideas?
the folder where is stored is this (i'm on win 7 64 bits):
C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
Do you have RequestExecutionLevel in your script? Without it Windows might do some compatibility hacks with your shortcuts.
If that does not help, try Process Monitor, it might be able to shed some light on the issue...

NSIS uninstaller - App Name missing (set dynamically)

I created an NSIS installer where the name of the app is taken from an .INI file (it has to be so since it will be used for multiple apps).
Name $APP_NAME
....
Function .onInit
ReadINIStr $R3 ${TECHPUB_INI_FILE} "General" "Installer_name"
StrCpy $APP_NAME $R3
....
FunctionEnd
....
Section install
....
WriteUninstaller $INSTDIR\Uninstall.exe
....
SectionEnd
The app name is correctly shown on the installer and it's the one from the .INI file. When I uninstall the app, the name is missing.
http://i48.tinypic.com/1934w9.png
Everything else works (uninstall removes all it has to remove). Any idea how to fix this?
Thank you!
The init function of the uninstaller is a separate un.onInit function. See Uninstall Callbacks.

NSIS Overwrites Shortcuts

Is there any way to tell NSIS not to overwrite my start menu shortcut. The reason I don't want it to overwrite is so the user's command line options aren't cleared when they upgrade to a new version. I've tried this to no avail:
Section -AdditionalIcons
SetOverwrite off
CreateDirectory "${START_MENU_DIR}"
CreateShortCut "${START_MENU_LNK}" "$INSTDIR\${PRODUCT_NAME}.exe"
SectionEnd
Why can't you just check with IfFileExists ?
If you wanted to go all out, you could update the path and working dir, but leave the parameters and icon in place, but to do that you would have to call the IShellLink COM interface on your own (With the system plugin or a custom plugin/app)
Here is an example that works:
Section -AdditionalIcons
CreateDirectory "${START_MENU_DIR}"
IfFileExists "${START_MENU_LNK}" SkipShortcut
CreateShortCut "${START_MENU_LNK}" "$INSTDIR\${PRODUCT_NAME}.exe"
SkipShortcut:
SectionEnd

Resources