-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDeployWiz_ProductKeyVista.vbs
executable file
·186 lines (139 loc) · 5.05 KB
/
DeployWiz_ProductKeyVista.vbs
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
' // ***************************************************************************
' //
' // Copyright (c) Microsoft Corporation. All rights reserved.
' //
' // Microsoft Deployment Toolkit Solution Accelerator
' //
' // File: DeployWiz_Initialization.vbs
' //
' // Version: 6.3.8330.1000
' //
' // Purpose: Main Client Deployment Wizard Initialization routines
' //
' // ***************************************************************************
Option Explicit
Dim iVerMajor
oUtility.GetMajorMinorVersion(Property("ImageBuild"))
iVerMajor = oUtility.VersionMajor
Function InitializeProductKey
' Figure out how to initialize the pane.
If Property("ProductKey") <> "" or iVerMajor < 6 then
locProductKey.disabled = false
locProductKey.value = Property("ProductKey")
ProductKey.value = locProductKey.value
If iVerMajor > 6 then
PKRadio3.click
locOverrideProductKey.disabled = true
OverrideProductKey.value = ""
End if
ElseIf Property("OverrideProductKey") <> "" then
PKRadio2.click
locOverrideProductKey.disabled = false
locProductKey.disabled = true
locOverrideProductKey.value = Property("OverrideProductKey")
OverrideProductKey.value = locOverrideProductKey.value
ProductKey.value = ""
Else
PKRadio1.click
locOverrideProductKey.disabled = true
locProductKey.disabled = true
ProductKey.value = ""
OverrideProductKey.value = ""
End if
if oProperties("DeploymentType") = "UPGRADE" then
document.getElementById("MAK_Text_tr").style.display = "none"
document.getElementById("MAK_Radio_tr").style.display = "none"
End if
End Function
Function ValidateProductKey
ValidateProductKey = False
If iVerMajor < 6 then
' Make sure the product key is valid
If locProductKey.value = "" then
PKBlank.style.display = "inline"
PKInvalid.style.display = "none"
ElseIf IsEmpty(GetProductKey(locProductKey.value)) then
PKBlank.style.display = "none"
PKInvalid.style.display = "inline"
Else
PKBlank.style.display = "none"
PKInvalid.style.display = "none"
ProductKey.value = GetProductKey(locProductKey.value)
ValidateProductKey = True
End if
ElseIf PKRadio1.checked then
locOverrideProductKey.disabled = true
locProductKey.disabled = true
OverrideBlank.style.display = "none"
OverrideInvalid.style.display = "none"
PKBlank.style.display = "none"
PKInvalid.style.display = "none"
ProductKey.value = ""
OverrideProductKey.value = ""
ValidateProductKey = True
ElseIf PKRadio2.checked then
locOverrideProductKey.disabled = false
locProductKey.disabled = true
PKBlank.style.display = "none"
PKInvalid.style.display = "none"
' Make sure the MAK key is valid
If locOverrideProductKey.value = "" then
OverrideBlank.style.display = "inline"
OverrideInvalid.style.display = "none"
ElseIf IsEmpty(GetProductKey(locOverrideProductKey.value)) then
OverrideBlank.style.display = "none"
OverrideInvalid.style.display = "inline"
Else
OverrideBlank.style.display = "none"
OverrideInvalid.style.display = "none"
OverrideProductKey.value = GetProductKey(locOverrideProductKey.value)
ProductKey.value = ""
ValidateProductKey = True
End if
Else
locOverrideProductKey.disabled = true
locProductKey.disabled = false
OverrideBlank.style.display = "none"
OverrideInvalid.style.display = "none"
' Make sure the product key is valid
If locProductKey.value = "" then
PKBlank.style.display = "inline"
PKInvalid.style.display = "none"
ElseIf IsEmpty(GetProductKey(locProductKey.value)) then
PKBlank.style.display = "none"
PKInvalid.style.display = "inline"
Else
PKBlank.style.display = "none"
PKInvalid.style.display = "none"
ProductKey.value = GetProductKey(locProductKey.value)
OverrideProductKey.value = ""
ValidateProductKey = True
End if
End if
End Function
const PRODUCT_KEY_TEST = "([0-9A-Z]+)?[^0-9A-Z]*([0-9A-Z]{5})[^0-9A-Z]?([0-9A-Z]{5})[^0-9A-Z]?([0-9A-Z]{5})[^0-9A-Z]?([0-9A-Z]{5})[^0-9A-Z]?([0-9A-Z]{5})[^0-9A-Z]*([0-9A-Z]+)?" '
Function GetProductKey( pk )
Dim regEx, match
Set regEx = New RegExp
regEx.Pattern = PRODUCT_KEY_TEST
regex.IgnoreCase = TRUE
For each match in regEx.Execute( UCase(pk) )
If IsEmpty(match.SubMatches(0)) and IsEmpty(match.SubMatches(6)) then
GetProductKey = ucase( match.SubMatches(1) & "-" & match.SubMatches(2) & "-" & _
match.SubMatches(3) & "-" & match.SubMatches(4) & "-" & match.SubMatches(5) )
End if
Exit function
Next
End function
Function AssignProductKey
If not IsEmpty(GetProductKey(locProductKey.value)) then
locProductKey.value = GetProductKey(locProductKey.value)
oEnvironment.Item("ProductKey") = locProductKey.value
End if
If iVerMajor >= 6 then
If not IsEmpty(GetProductKey(locOverrideProductKey.value)) then
locOverrideProductKey.value = GetProductKey(locOverrideProductKey.value)
oEnvironment.Item("OverrideProductKey") = locOverrideProductKey.value
End if
End if
End Function