-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkNet.nsi
156 lines (125 loc) · 4.53 KB
/
checkNet.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
; Script generated by the HM NIS Edit Script Wizard.
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "wutau安裝檔"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "EASYCHAIN TECHNOLOGY CO.,LTD"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
SetCompressor bzip2
; MUI 1.67 compatible ------
!include "MUI.nsh"
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
; Language Selection Dialog Settings
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_LANGUAGE "TradChinese"
; Reserve files
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
!define NETVersion "3.5"
!define NETInstaller "dotNetFx35setup.exe"
!define NET4 "4.0.30319"
!define NET4Installer "dotNetFx40_Full_x86_x64.exe"
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "chechnet.exe"
InstallDir "C:\inetpub"
ShowInstDetails show
ShowUnInstDetails show
/*
Function .onInit
;?查是否安?了3.5
StrCpy $DotNetFrameworkVersion 3.5
Push $DotNetFrameworkVersion
Call CheckDotNetFramework
Exch $R0
${If} $R0 == "1" ; ?有找到
MessageBox MB_ICONSTOP|MB_OK "程序運行所必需的 Microsoft .NET Framework$DotNetFrameworkVersion 尚未安裝,請先安裝Microsoft .NET Framework$DotNetFrameworkVersion。" IDYES
abort
${ElseIf} $R0 == "0" ; 找到指定版本的DotNetFramework
;?查是否安?了4.0
pop $DotNetFrameworkVersion
StrCpy $DotNetFrameworkVersion 4.0
Push $DotNetFrameworkVersion
Call CheckDotNetFramework
Exch $R0
${If} $R0 == "1"
MessageBox MB_ICONSTOP|MB_OK "程序運行所必需的 Microsoft .NET Framework$DotNetFrameworkVersion 尚未安裝,請先安裝Microsoft .NET Framework$DotNetFrameworkVersion。" IDYES
abort
${EndIf}
${Endif}
FunctionEnd
*/
Function .onInit
FunctionEnd
Section "MS .NET Framework v${NETVersion}" SecFramework
IfFileExists "$WINDIR\Microsoft.NET\Framework\v${NETVersion}" NETFrameworkInstalled 0
File /oname=$TEMP\${NETInstaller} ${NETInstaller}
DetailPrint "Starting Microsoft .NET Framework v${NETVersion} Setup..."
ExecWait "$TEMP\${NETInstaller}"
Return
NETFrameworkInstalled:
;MessageBox MB_ICONSTOP|MB_OK "Microsoft .NET Framework v${NETVersion} 已經安裝。" IDYES
DetailPrint "Microsoft .NET Framework is already installed!"
SectionEnd
Section "MS .NET Framework v${NET4}" SecNETFramework4
IfFileExists "$WINDIR\Microsoft.NET\Framework\v${NET4}" NETFrameworkInstalled 0
File /oname=$TEMP\${NET4Installer} ${NET4Installer}
DetailPrint "Starting Microsoft .NET Framework v${NET4} Setup..."
ExecWait "$TEMP\${NET4Installer}"
Return
NETFrameworkInstalled:
MessageBox MB_ICONSTOP|MB_OK "Microsoft .NET Framework v${NET4} 已經安裝。" IDYES
DetailPrint "Microsoft .NET Framework is already installed!"
SectionEnd
Function CheckDotNetFramework
/* Exchange $R0 with the top of the stack to get the value passed by caller */
Exch $R0
/* Save other NSIS registers */
Push $R1
Push $R2
Push $R3
/* Zero out $R2 for the indexer */
StrCpy $R3 "0"
loop:
/* Get each sub key under "SOFTWARE\Microsoft\NET Framework Setup\NDP" */
EnumRegKey $R1 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP" $R3
StrCmp $R1 "" version_not_found /* Requested version is not found */
StrCpy $R2 $R1 "" 1 /* Remove "v" from subkey */
StrCmp $R2 $R0 version_found /* Requested version is found */
IntOp $R3 $R3 + 1 /* Increment registry key index */
Goto loop
/* The requested .Net Framework version WAS NOT FOUND on this system */
version_not_found:
/* Restore the registers saved earlier */
Pop $R3
Pop $R2
Pop $R1
Pop $R0
Push "1" /* Put "1" on the top of the stack for caller to use */
Goto end
/* The requested .Net Framework version WAS FOUND on this system */
version_found:
/* Restore the registers saved earlier */
Pop $R3
Pop $R2
Pop $R1
Pop $R0
Push "0" /* Put "0" on the top of the stack for caller to use */
end:
FunctionEnd