| 2031 |
ghuddy |
1 |
;------------------------------------------------------------------------------
|
|
|
2 |
; Code originally from http://nsis.sourceforge.net/How_to_ensure_a_required_version_of_.NET_Framework_is_installed
|
|
|
3 |
;
|
|
|
4 |
; This macro checks that a specified dot net version is present in the target
|
|
|
5 |
; machine.
|
|
|
6 |
;
|
|
|
7 |
; usage:
|
|
|
8 |
; !insertmacro DotNetSearch 4 0 30319 "ABORT" ""
|
|
|
9 |
;
|
|
|
10 |
; Parameters:
|
|
|
11 |
; 1 DOTNETVMAJOR Compulsory, minimum major version required
|
|
|
12 |
; 2 DOTNETVMINOR Compulsory, minimum minor version required
|
|
|
13 |
; 3 DOTNETVMINORMINOR Option minimum build version required. Set to "" if not important
|
|
|
14 |
; 4 DOTNETLASTFUNCTION What to do if no dot net found
|
|
|
15 |
; One of the following :
|
|
|
16 |
; INSTALL_ABORT : Give user option of installing it, or aborting
|
|
|
17 |
; INSTALL_NOABORT : Give user option of installing it, or returning
|
|
|
18 |
; to caller and let them decide on action needed
|
|
|
19 |
; WARNING : Just issue a warning and return to caller and let
|
|
|
20 |
; them decide on action needed
|
|
|
21 |
; ABORT : Abort the installer
|
|
|
22 |
; IGNORE : Just return to caller and let them decide on
|
|
|
23 |
; action needed
|
|
|
24 |
; 5 DOTNETINSTALLEREXE Path to dotnet exe to install the dotnet framework
|
|
|
25 |
;------------------------------------------------------------------------------
|
|
|
26 |
Var /GLOBAL DNS_RETVAL
|
|
|
27 |
Var /GLOBAL DNS_SUBKEY
|
|
|
28 |
Var /GLOBAL DNS_REGKEY2
|
|
|
29 |
Var /GLOBAL DNS_REGKEY
|
|
|
30 |
Var /GLOBAL DNS_TMPSTR
|
|
|
31 |
Var /GLOBAL DNS_ENUMINDEX
|
|
|
32 |
Var /GLOBAL DNA_INSTALLROOT
|
|
|
33 |
Var /GLOBAL DOTNETPATH
|
|
|
34 |
|
|
|
35 |
!macro DotNetSearch DOTNETVMAJOR DOTNETVMINOR DOTNETVMINORMINOR DOTNETLASTFUNCTION DOTNETINSTALLEREXE
|
|
|
36 |
Push $DNS_RETVAL
|
|
|
37 |
Push $DNS_SUBKEY
|
|
|
38 |
Push $DNS_REGKEY2
|
|
|
39 |
Push $DNS_REGKEY
|
|
|
40 |
Push $DNS_TMPSTR
|
|
|
41 |
Push $DNS_ENUMINDEX
|
|
|
42 |
Push $DNA_INSTALLROOT
|
|
|
43 |
|
|
|
44 |
StrCpy $DNS_RETVAL "0"
|
|
|
45 |
StrCpy $DNS_SUBKEY "SOFTWARE\Microsoft\.NETFramework"
|
|
|
46 |
StrCpy $DNS_ENUMINDEX 0
|
|
|
47 |
|
|
|
48 |
; Here is where we start to iterate over the registry area that lists evidence of the installed dotnet frameworks
|
|
|
49 |
|
|
|
50 |
DotNetStartEnum:
|
|
|
51 |
; Look in HKLM\SOFTWARE\Microsoft\.NETFramework\policy for v?.?
|
|
|
52 |
EnumRegKey $DNS_REGKEY HKLM "$DNS_SUBKEY\policy" $DNS_ENUMINDEX
|
|
|
53 |
StrCmp $DNS_REGKEY "" noDotNet dotNetFound
|
|
|
54 |
dotNetFound:
|
|
|
55 |
; Does entry begin with "v"?
|
|
|
56 |
StrCpy $DNS_TMPSTR $DNS_REGKEY 1 0
|
|
|
57 |
StrCmp $DNS_TMPSTR "v" +1 goNextDotNet
|
|
|
58 |
|
|
|
59 |
; Examine major version of in the "v?.?" string
|
|
|
60 |
StrCpy $DNS_TMPSTR $DNS_REGKEY 1 1
|
|
|
61 |
IntCmp $DNS_TMPSTR ${DOTNETVMAJOR} +1 goNextDotNet yesDotNetReg
|
|
|
62 |
|
|
|
63 |
; Examine minor version of in the "v?.?" string
|
|
|
64 |
StrCpy $DNS_TMPSTR $DNS_REGKEY 1 3
|
|
|
65 |
IntCmp $DNS_TMPSTR ${DOTNETVMINOR} +1 goNextDotNet yesDotNetReg
|
|
|
66 |
|
|
|
67 |
; Has caller specified a dotnet BUILD version number ?
|
|
|
68 |
StrCmp ${DOTNETVMINORMINOR} "" yesDotNetReg +1
|
|
|
69 |
|
|
|
70 |
; Look in HKLM\SOFTWARE\Microsoft\.NETFramework\policy\v?.? for the build version key and
|
|
|
71 |
; compare it to caller specified value. It is acceptable if it is equal to or greater than
|
|
|
72 |
; the caller specified value
|
|
|
73 |
EnumRegValue $DNS_TMPSTR HKLM "$DNS_SUBKEY\policy\$DNS_REGKEY" 0
|
|
|
74 |
StrCmp $DNS_TMPSTR "" goNextDotNet
|
|
|
75 |
IntCmpU $DNS_TMPSTR ${DOTNETVMINORMINOR} yesDotNetReg goNextDotNet yesDotNetReg
|
|
|
76 |
|
|
|
77 |
goNextDotNet:
|
|
|
78 |
; Increment index into the enumerated list of keys and advance to next iteration
|
|
|
79 |
IntOp $DNS_ENUMINDEX $DNS_ENUMINDEX + 1
|
|
|
80 |
Goto DotNetStartEnum
|
|
|
81 |
|
|
|
82 |
yesDotNetReg:
|
|
|
83 |
; Looks like we have a dotnet version required.
|
|
|
84 |
; Look in HKLM\SOFTWARE\Microsoft\.NETFramework\policy\v?.? for the build version key and use it
|
|
|
85 |
; to form a path we can check for the presence of actual files in a dotnet framework installation
|
|
|
86 |
EnumRegValue $DNS_REGKEY2 HKLM "$DNS_SUBKEY\policy\$DNS_REGKEY" 0
|
|
|
87 |
StrCmp $DNS_REGKEY2 "" noDotNet
|
|
|
88 |
|
|
|
89 |
; Look in HKLM\SOFTWARE\Microsoft\.NETFramework\ for the installation root folder path
|
|
|
90 |
ReadRegStr $DNA_INSTALLROOT HKLM $DNS_SUBKEY "InstallRoot"
|
|
|
91 |
StrCmp $DNA_INSTALLROOT "" noDotNet
|
|
|
92 |
|
|
|
93 |
; Check for existence of the mscorlib.dll in the file system to prove the dot net framework has been installed
|
|
|
94 |
; DNA_INSTALLROOT contains something like "c:\WINDOWS\Microsoft.NET\Framework\"
|
|
|
95 |
; DNS_REGKEY contains something like "v4.0"
|
|
|
96 |
; DNS_REGKEY2 contains something like "30319"
|
|
|
97 |
StrCpy $DOTNETPATH "$DNA_INSTALLROOT$DNS_REGKEY.$DNS_REGKEY2"
|
|
|
98 |
|
|
|
99 |
StrCpy $DNS_TMPSTR "$DOTNETPATH\mscorlib.dll"
|
|
|
100 |
IfFileExists $DNS_TMPSTR +1 noDotNet
|
|
|
101 |
|
|
|
102 |
; Check for existence of the installutil.exe in the file system to prove the dot net framework has been installed
|
|
|
103 |
StrCpy $DNS_TMPSTR "$DOTNETPATH\installutil.exe"
|
|
|
104 |
IfFileExists $DNS_TMPSTR yesDotNet noDotNet
|
|
|
105 |
|
|
|
106 |
noDotNet:
|
|
|
107 |
StrCmp ${DOTNETLASTFUNCTION} "INSTALL_ABORT" +1 nDN2
|
|
|
108 |
MessageBox MB_YESNO|MB_ICONQUESTION \
|
|
|
109 |
"You must have Microsoft .NET Framework version ${DOTNETVMAJOR}.${DOTNETVMINOR}.${DOTNETVMINORMINOR}$\nor higher installed. Install now?" \
|
|
|
110 |
IDYES +2 IDNO +1
|
|
|
111 |
Abort
|
|
|
112 |
ExecWait '${DOTNETINSTALLEREXE}'
|
|
|
113 |
Goto DotNetStartEnum
|
|
|
114 |
nDN2:
|
|
|
115 |
StrCmp ${DOTNETLASTFUNCTION} "INSTALL_NOABORT" +1 nDN3
|
|
|
116 |
MessageBox MB_YESNO|MB_ICONQUESTION \
|
|
|
117 |
"Microsoft .NET Framework version ${DOTNETVMAJOR}.${DOTNETVMINOR}.${DOTNETVMINORMINOR} is not installed.$\nDo so now?" \
|
|
|
118 |
IDYES +1 IDNO +3
|
|
|
119 |
ExecWait '${DOTNETINSTALLEREXE}'
|
|
|
120 |
Goto DotNetStartEnum
|
|
|
121 |
StrCpy $DNS_RETVAL 0
|
|
|
122 |
Goto DotNetFinish
|
|
|
123 |
nDN3:
|
|
|
124 |
StrCmp ${DOTNETLASTFUNCTION} "WARNING" +1 nDN4
|
|
|
125 |
MessageBox MB_OK|MB_ICONEXCLAMATION \
|
|
|
126 |
"Warning:$\n$\n$\t$\tMicrosoft .NET Framework version$\n$\t$\t${DOTNETVMAJOR}.${DOTNETVMINOR}.${DOTNETVMINORMINOR} is not installed!" \
|
|
|
127 |
IDOK 0
|
|
|
128 |
StrCpy $DNS_RETVAL 0
|
|
|
129 |
Goto DotNetFinish
|
|
|
130 |
nDN4:
|
|
|
131 |
StrCmp ${DOTNETLASTFUNCTION} "ABORT" +1 nDN5
|
|
|
132 |
MessageBox MB_OK|MB_ICONEXCLAMATION \
|
|
|
133 |
"Error:$\n$\n$\t$\tMicrosoft .NET Framework version$\n$\t$\t${DOTNETVMAJOR}.${DOTNETVMINOR}.${DOTNETVMINORMINOR} is not installed, aborting!" \
|
|
|
134 |
IDOK 0
|
|
|
135 |
Abort
|
|
|
136 |
nDN5:
|
|
|
137 |
StrCmp ${DOTNETLASTFUNCTION} "IGNORE" +1 nDN6
|
|
|
138 |
StrCpy $DNS_RETVAL 0
|
|
|
139 |
Goto DotNetFinish
|
|
|
140 |
nDN6:
|
|
|
141 |
MessageBox MB_OK \
|
|
|
142 |
"$(^Name) Setup internal error.$\nMacro 'DotNetSearch', parameter '4'(${DOTNETLASTFUNCTION})invalid.$\nValue must be INSTALL_ABORT|INSTALL_NOABORT|WARNING|ABORT|IGNORE$\nSorry for the inconvenience.$\n$\tAborting..." \
|
|
|
143 |
IDOK 0
|
|
|
144 |
Abort
|
|
|
145 |
|
|
|
146 |
yesDotNet:
|
|
|
147 |
StrCpy $DNS_RETVAL 1
|
|
|
148 |
|
|
|
149 |
DotNetFinish:
|
|
|
150 |
Pop $DNA_INSTALLROOT
|
|
|
151 |
Pop $DNS_ENUMINDEX
|
|
|
152 |
Pop $DNS_TMPSTR
|
|
|
153 |
Pop $DNS_REGKEY
|
|
|
154 |
Pop $DNS_REGKEY2
|
|
|
155 |
Pop $DNS_SUBKEY
|
|
|
156 |
Exch $DNS_RETVAL
|
|
|
157 |
!macroend
|