Archive: Driving me mad, what is $0 and how to I use it?


Driving me mad, what is $0 and how to I use it?
Hello, I tried reading up on the documentation for NSIS but the documentation just dives right into using $0 without explaining what it is or how it works and I can't wrap my head around what is probably a very simple thing.

What is the $0 variable/function what is it? and how does it work in code?

I have this function I found to check for .Net framework and download it from the microsoft web site if it's not installed on the machine. I wanted to expand the code to also check for XNA framework using the XNA framework's registry key but when I make my installer it always pops up a window to install XNA even though it's already installed on my machine.

I've been trying to troubleshoot this myself but I need to know what is $0???? I have a feeling that $0 cannot be used to check for XNA. But I can't find any information about $0 or $1 or anything to help me figure this out in the normal documentation..

Here is my code:

ReadRegDWORD $0 HKLM 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5' Install
${If} $0 == ''
StrCpy $InstallDotNET "Yes"
MessageBox MB_OK|MB_ICONINFORMATION "${PRODUCT_NAME} requires that the .NET Framework 3.5 is installed. The .NET Framework will be downloaded and installed automatically during installation of ${PRODUCT_NAME}."
Return
${EndIf}

ReadRegDWORD $0 HKLM 'SOFTWARE\Microsoft\XNA\Framework\v3.1' Install
${If} $0 == ''
StrCpy $InstallXNAFramework "Yes"
MessageBox MB_OK|MB_ICONINFORMATION "${PRODUCT_NAME} requires the XNA Framework to function properly. The XNA Framework will be downloaded and installed automatically during installation of ${PRODUCT_NAME}."
Return
${EndIf}



And later down the script file...


; Get .NET if required
${If} $InstallDotNET == "Yes"
SetDetailsView hide
inetc::get /caption "Downloading .NET Framework 3.5" /canceltext "Cancel" "http://download.microsoft.com/download/7/0/3/703455ee-a747-4cc8-bd3e-98a615c3aedb/dotNetFx35setup.exe" "$INSTDIR\dotNetFx35setup.exe" /end
Pop $1

${If} $1 != "OK"
Delete "$INSTDIR\dotNetFx35setup.exe"
Abort "Installation cancelled."
${EndIf}

ExecWait "$INSTDIR\dotNetFx35setup.exe"
Delete "$INSTDIR\dotNetFx35setup.exe"

SetDetailsView show
${EndIf}

; Get XNA if required
${If} $InstallXNAFramework == "Yes"
SetDetailsView hide
inetc::get /caption "Downloading XNA Framework 3.1" /canceltext "Cancel" "http://download.microsoft.com/download/5/9/1/5912526C-B950-4662-99B6-119A83E60E5C/xnafx31_redist.msi" "$INSTDIR\xnafx31_redist.msi" /end
Pop $2

${If} $2 != "OK"
Delete "$INSTDIR\xnafx31_redist.msi"
Abort "Installation cancelled."
${EndIf}

ExecWait "$INSTDIR\xnafx31_redist.msi"
Delete "$INSTDIR\xnafx31_redist.msi"

SetDetailsView show
${EndIf}

http://nsis.sourceforge.net/Docs/Chapter2.html#2.3.5.2

It's all right there in the manual.


HKLM 'SOFTWARE\Microsoft\XNA\Framework\v3.1' Install exists and it's a DWORD?

Stu