Archive: Loading Prerequisites issue


Loading Prerequisites issue
  For my application, I have a lot of prerequisite requirements.

I decided to switch to NSIS so that I could more easily install them without having to bloat the installer to over 400MB. Now my installer is 35MB.

I am having an issue with checking for prerequisites. I look for the registry keys that these programs create; however, if I loaded the program during the running install, the registry has not been updated and thus I do not see it.

Since I have several optional components that have some of the same prerequisites, this was causing me to download and install the same app several times. I fixed this with a global variable to track which programs I already installed.

Now, the only issue I have involves SQL. I install the SQL Express and then try to use sqlcmd to load the database. Path to sqlcmd is not loaded. I can get around this by hard coding the full path to sqlcmd but under some circumstances this could be an issue.

Is there a way to reload the registry during the install so that changes made can be seen?


The registry is always synchronous. There's no need to reload it anywhere. You probably mean environment variables. Those are only loaded once when the process starts or when a special message is sent, and even then, only by explorer.exe.

The best you can probably do in this case is get the explicit path of sqlcmd.exe, from the registry or elsewhere, and use that instead of relying on it being found in the PATH.


I appreciate your quick response. Here is a code snip


macro CheckWMV 

DetailPrint "Checking for WMV files..."

ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\WMV9_VCM" "File Location"
>IfErrors 0 GOTWMV
DetailPrint "Beginning download of wmv9VCM."
NSISDL::download ${WMVVCM_URL} "$TEMP\wmv9VCMsetup.exe"
DetailPrint "Completed download."
Pop $0
${If} $0 == "cancel"
MessageBox MB_YESNO|MB_ICONEXCLAMATION "Download cancelled. Continue Installation?" IDYES GOTWMV IDNO GOTWMV
${ElseIf} $0 != "success"
MessageBox MB_YESNO|MB_ICONEXCLAMATION "Download failed:$\n$0$\n$\nContinue Installation?" IDYES GOTWMV IDNO GOTWMV
${EndIf}
DetailPrint "Pausing installation while downloaded wmv9VCM installer runs."
ExecWait '$TEMP\wmv9VCMsetup.exe /q'
DetailPrint "Completed wmv9VCM install/update. Removing installer."
Delete "$TEMP\wmv9VCMsetup.exe"
DetailPrint "wmv9VCM installer removed."
>GOTWMV:
DetailPrint "Proceeding with remainder of installation."
>!macroend
>
This is a sample of how I have been checking. I run this code in one section, it checks and gets an error when reading the registry so it downloads the setup file and installs it. If I rerun my installer, any further calls to this code get a good read and thus we skip the d/l.

If during the same instance the file gets d/l, a second section calls this code, the registry still does not show the data and thus we d/l again.

I fixed this by using a global variable to indicate that wmv9vcm was already installed once this instance; however, I don't like using global variables in general and would like to know how to make this work without.

The sql path is also in the registry (that is where I pull it from) however, I can also get the environment path.

As I said, I have things working but I don't like having the path hard coded in case the sql files are not installed in C:\Program Files\Microsoft SQL Server\....

You must use ClearErrors before ReadRegStr or else you might catch errors that occurred earlier in the script.