Archive: Is this right ?? (NSISdl & ZipDLL usage)


Is this right ?? (NSISdl & ZipDLL usage)
I'm using Modern UI and I'm just curious if this will end up working properly once the installer is all done.
I'm downloading DLL's using NSISdl, and then unziping them to windows temp dir (I think), and then using Upgrade DLL macro to install and register the dll. If there is a problem with my code please let me know.

;----------------------- ASYCFILT.DLL ----------------------------------------------------------------------
IfFileExists $SYSDIR\Comcat.dll skipDLL2
NSISdl::download /TIMEOUT=30000 http://www.mdb-project.com/Downloads/dll/asycfilt.zip $TEMP\asycfilt.zip
Pop $R0 ;Get the return value
StrCmp $R0 "success" +3
MessageBox MB_OK "Download failed: $R0"
Quit
ZipDLL::extractall "$TEMP\asycfilt.zip" "$TEMP"
!insertmacro UpgradeDLL $TEMP\asycfilt.dll $SYSDIR\asycfilt.dll
skipDLL2:


as per the above example, this is the error I end up with (attempting to compile the script when the DLL doesn't exist I guess)

I guess the problem is that it's running the script (attempting to getdllversion) on a file that will only exist during runtime ? .. how do I get around this ?


IfFileExists: "$SYSDIR\Comcat.dll" ? skipDLL1 :
File: "nsisdl.dll"->"$PLUGINSDIR\nsisdl.dll" 13312 bytes
Plugin Command: download /TIMEOUT=30000 http://www.mdb-project.com/Downloads/dll/Comcat.zip $TEMP\Comcat.zip
Pop: $R0
StrCmp "$R0" "success" equal=+3, nonequal=
MessageBox: 0: "Download failed: $R0"
Quit
Plugin Command: extractall $TEMP\Comcat.zip $TEMP
!insertmacro: UpgradeDLL
Push: $R0
Push: $R1
Push: $R2
Push: $R3
IfFileExists: "$SYSDIR\Comcat.dll" ? : copy_$TEMP\Comcat.dll
ClearErrors
GetDLLVersionLocal: error reading version info from "$TEMP\Comcat.dll"
Error in macro UpgradeDLL on macroline 13


The first parameter of UpgradeDLL is the location of the file on your computer (the creator of the installer).

UpgradeDLL included the DLL file in your installer, if you want to download a DLL, you will have to modify the macro.


Thanks for your reply Joost. I have no created a small macro to download the DLL's I need and the NSISdl will ALWAYS error. in the Detail view it shows "Error: (3 unledgible characters)mission denied"
and in the msgbox it says "Error: Online". There should be no permission problem, I say this because I've given pretty much every possible account read access to the files located on the server, all users can access the files through IE. Is there something I'm missing ? (I'm using the Dailer to verify internet connection long before the downloads happen). Also it is trying to download asycfilt.dll which is already in my "C:\Winnt\System32" folder, so shouldn't it be skipped alltogether ? ...

Here is how I'm Calling DLL d/l's:
!insertmacro DoDllWork "asycfilt" "dll"
!insertmacro DoDllWork "Comcat" "dll"
!insertmacro DoDllWork "comdlg32" "ocx"

And The Macro:
!macro DoDllWork FILENAME EXT
DetailPrint "${FILENAME}.${EXT}"
DetailPrint "URL: http://www.mdb-project.com/Downloads/dll/${FILENAME}.zip"
DetailPrint "$SYSDIR\${FILENAME}.${EXT}"
IfFileExists "$SYSDIR\${FILENAME}.${EXT}" +8
NSISdl::download "http://www.mdb-project.com/Downloads/dll/${FILENAME}.zip" "C:\${FILENAME}.zip"
Pop $R0 ;Get the return value
StrCmp $R0 "success" +3
MessageBox MB_OK "Download failed: $R0"
Quit
ZipDLL::extractall "$TEMP\${FILENAME}.zip" "$SYSDIR"
Delete "$TEMP\${FILENAME}.zip"
RegDLL "${FILENAME}.${EXT}"

!macroend

I've put in a few extra DetailPrints in there to verify paths are correct, and all seems good. If anyone could please shed some light on this matter it would be greatly appriciated.

Thanks,


All fixed :) ... looked in docs and discovered IfFileExists only supports labels, not +N ... still not sure why that made NSISdl crap out but it works so I'm happy. And for anyone else this is a great little macro for D/L'ing and Reg'in DLL's :) ...


!macro DoDllWork FILENAME EXT
IfFileExists "$SYSDIR\${FILENAME}.${EXT}" skip${FILENAME}
NSISdl::download http://www.mdb-project.com/Downloads/dll/${FILENAME}.zip $TEMP\${FILENAME}.zip
Pop $R0 ;Get the return value
StrCmp $R0 "success" +3
MessageBox MB_OK "Download failed: $R0"
Quit
ZipDLL::extractall "$TEMP\${FILENAME}.zip" "$SYSDIR"
Delete "$TEMP\${FILENAME}.zip"
RegDLL "${FILENAME}.${EXT}"
skip${FILENAME}:
!macroend


IfFileExists does support jumps, but the problem is the plug-ins call. Certain commands are being processed to multiple commands internally, so you can't use relative jumps.

From the docs:

Note: relative jumps don't work with Exch, File, plug-ins (Plugin::Function), InitPluginsDir, GetFileTimeLocal or GetDLLVersionLocal. Do not try to jump over them using relative jumps, you will not get the result you were expecting.


I think that the compiler should throw a warning when an instruction is trying to jump over those instructions. It is often not seen as an error, since the compiler still compiles the installer correctly.


Adding such a check is not easy. This limitation will be gone soon, so there is no need to work on that now.