NSIs: An Example of judging and installing. NET Framework
Currently, software developed by. NET is widely used, but some operating systems do not meet the running requirements of the software. Therefore, we need to installProgram. NET Framework. If it does not meet the requirements, install it silently.
First, we will judge the current. Net version in the function section:
Function getnetframeworkversion
; Obtain the. NET Framework version. Supported
Push $1
Push $0
Readregdword $0 HKLM "SOFTWARE \ Microsoft \ Net Framework Setup \ NDP \ v3.5" "Install"
Readregdword $1 HKLM "SOFTWARE \ Microsoft \ Net Framework Setup \ NDP \ v3.5" "version"
Strcmp $0 1 knownetframeworkversion + 1
Readregdword $0 HKLM "SOFTWARE \ Microsoft \ Net Framework Setup \ NDP \ V3.0 \ setup" "installsuccess"
Readregdword $1 HKLM "SOFTWARE \ Microsoft \ Net Framework Setup \ NDP \ V3.0 \ setup" "version"
Strcmp $0 1 knownetframeworkversion + 1
Readregdword $0 HKLM "SOFTWARE \ Microsoft \ Net Framework Setup \ NDP \ v2.0.50727" "Install"
Readregdword $1 HKLM "SOFTWARE \ Microsoft \ Net Framework Setup \ NDP \ v2.0.50727" "version"
Strcmp $1 "" + 1 + 2
Strcpy $1 "2.0.50727.832"
Strcmp $0 1 knownetframeworkversion + 1
Readregdword $0 HKLM "SOFTWARE \ Microsoft \ Net Framework Setup \ NDP \ v1.1.4322" "Install"
Readregdword $1 HKLM "SOFTWARE \ Microsoft \ Net Framework Setup \ NDP \ v1.1.4322" "version"
Strcmp $1 "" + 1 + 2
Strcpy $1 "1.1.4322.573"
Strcmp $0 1 knownetframeworkversion + 1
Readregdword $0 HKLM "SOFTWARE \ Microsoft \. netframework \ Policy \ V1.0" "Install"
Readregdword $1 HKLM "SOFTWARE \ Microsoft \. netframework \ Policy \ V1.0" "version"
Strcmp $1 "" + 1 + 2
Strcpy $1 "1.0.3705.0"
Strcmp $0 1 knownetframeworkversion + 1
Strcpy $1 "not. netframework"
Knownetframeworkversion:
Pop $0
Exch $1
Functionend
Then, perform. Net Silent Installation in the section.
Section-. net
Call getnetframeworkversion
Pop $ r1
$ {If} $ R1 <'2. 0.50727'
Setdetailsprint textonly
Detailprint "Installing. NET Framework 2.0 SP2 ..."
Setdetailsprint listonly
Setoutpath "$ Temp"
Setoverwrite on
File "netfx20sp2_x86.exe"
Execwait '$ Temp \ netfx20sp2_x86.exe/quiet/norestart' $ r1
Delete "$ Temp \ netfx20sp2_x86.exe"
$ {Endif}
Sectionend
Of course, the Section section can be automatically downloaded online without hitting. net in the installation package. This can reduce the size of the installation package. For more information, see the zichen account book installer.
Reprinted from: http://www.flighty.cn/html/bushu/20110527_126.html