Skip to content
⌘ NSIS Forum Archive

Trying to install or repair VC runtime

2 posts

perdrix#

Trying to install or repair VC runtime

I wrote this:

```
Section "Visual Studio Runtime"
SetOutPath "$INSTDIR"
File "..\x64\Release\vc_redist.x64.exe"
SetRegView 64
ReadRegDWORD $0 HKLM "Software\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\X64" "Bld"
SetRegView 32
${If} $0 != ""
${If} $0 < 33816
#
# vc_redist build 33816 isn't installed, so install it
#
ExecWait "$INSTDIR\vc_redist.x64.exe /install /passive /norestart"
${If} $0 == 33816
#
# vc_redist build 33816 is installed, force a repair install
#
ExecWait "$INSTDIR\vc_redist.x64.exe /repair /passive /norestart"
$ {Else}
# Don't recognise this
MessageBox mb_iconStop "Visual Studio Runtime Build" $0 "not recognised"
Abort
${Endif}
${Else}
#
# vc_redist build 33816 isn't installed, so install it
#
ExecWait "$INSTDIR\vc_redist.x64.exe /install /passive /norestart"
${Endif}

Delete "$INSTDIR\vc_redist.x64.exe"
SectionEnd

```

Sadly the compiler complains it isn't valid. (No, I'm not fluent in NSIS).

How should I rephrase it so that:

if the Bld regvar is null or less than 33816, then a regular install is done,

if the Bld regvar is equal to 33816 then a repair install will be done,

if the Bld regvar is > 33816 then abort with a nastygram

Thanks
David
Anders#
What is the compiler error, it probably also tells you the line where the problem is in your code! "$ {Else}" has a space typo for example...

!include LogicLib.nsh
Section
Quit
SetOutPath "$INSTDIR"
#File "..\x64\Release\vc_redist.x64.exe"
SetRegView 64
ReadRegDWORD $0 HKLM "Software\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\X64" "Bld"
SetRegView 32
${If} $0 != ""
${If} $0 < 33816
#
# vc_redist build 33816 isn't installed, so install it
#
ExecWait "$INSTDIR\vc_redist.x64.exe /install /passive /norestart"
${If} $0 == 33816
#
# vc_redist build 33816 is installed, force a repair install
#
ExecWait "$INSTDIR\vc_redist.x64.exe /repair /passive /norestart"
${Else}
# Don't recognise this
MessageBox mb_iconStop '"Visual Studio Runtime Build" $0 "not recognised"'
Abort
${Endif}
${Else}
#
# vc_redist build 33816 isn't installed, so install it
#
ExecWait "$INSTDIR\vc_redist.x64.exe /install /passive /norestart"
${Endif}
Delete "$INSTDIR\vc_redist.x64.exe"
SectionEnd