-
Notifications
You must be signed in to change notification settings - Fork 1
/
DeployWiz_Initialization.vbs
executable file
·200 lines (134 loc) · 6.67 KB
/
DeployWiz_Initialization.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
' // ***************************************************************************
' //
' // 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 g_oTaskSequences
Function oTaskSequences
If isempty(g_oTaskSequences) then
oLogging.CreateEntry "Begin InitializeTSList...", LogTypeVerbose
set g_oTaskSequences = new ConfigFile
g_oTaskSequences.sFileType = "TaskSequences"
g_oTaskSequences.sSelectionProfile = oEnvironment.Item("WizardSelectionProfile")
g_oTaskSequences.sCustomSelectionProfile = oEnvironment.Item("CustomWizardSelectionProfile")
g_oTaskSequences.sHTMLPropertyHook = " onPropertyChange='TSItemChange'"
set g_oTaskSequences.fnCustomFilter = GetRef("CustomTSFilter")
oLogging.CreateEntry "Finished InitializeTSList...", LogTypeVerbose
End if
set oTaskSequences = g_oTaskSequences
End function
function CustomTSFilter( sGuid, oItem )
' Hook for ZTIConfigFile.vbs. Return True only if the Item should be displayed, otherwise false.
Dim oTaskList
Dim oTaskOsGuid
Dim oOS
DIm sOSPlatform
Dim sOSBuild
Set oTaskList = oUtility.LoadConfigFileSafe( "Control\" & oUtility.SelectSingleNodeString(oItem,"ID") & "\TS.xml")
Set oTaskOsGuid = oTaskList.SelectSingleNode("//globalVarList/variable[@name='OSGUID']")
CustomTSFilter = True
If oTaskOsGuid is Nothing then
' This Task Sequence does not have any associated OS, allways include
ElseIf not AllOperatingSystems.Exists(oTaskOsGuid.text) then
' This Task Sequence does not have any associated OS, allways include
oLogging.CreateEntry "ERROR: Invalid OS GUID " & oTaskOsGuid.text & " specified for task sequence " & oUtility.SelectSingleNodeString(oItem,"ID"), LogTypeInfo
Else
set oOS = AllOperatingSystems.Item(oTaskOsGuid.text)
If not oOS.selectSingleNode("SMSImage") is nothing then
If ucase(oUtility.SelectSingleNodeString(oOS,"SMSImage")) = "TRUE" then
oLogging.CreateEntry "Skip SMS OS " & oUtility.SelectSingleNodeString(oItem,"ID"), LogTypeVerbose
CustomTSFilter = False
exit function
End if
End if
if not oOS.selectSingleNode("Platform") is nothing then
sOSPlatform = oUtility.SelectSingleNodeString(oOS,"Platform")
sOSBuild = oUtility.SelectSingleNodeString(oOS, "Build")
oUtility.GetMajorMinorVersion(sOSBuild)
If UCase(sOSPlatform) = UCase(oEnvironment.Item("Architecture")) then
' Same Archtecture as current OS, No problems.
ElseIf Instr(1, Property("CapableArchitecture"), sOSPlatform, vbTextCompare) = 0 then
oLogging.CreateEntry "Not Capable of running Platform: " & sOSPlatform & " " & oUtility.SelectSingleNodeString(oItem,"ID"), LogTypeInfo
CustomTSFilter = False
ElseIf UCase(sOSPlatform) = "X86" and UCase(oEnvironment.Item("Architecture")) = "X64" then
oLogging.CreateEntry "Skip cross platform x86 install from x64 Windows. " & oUtility.SelectSingleNodeString(oItem,"ID"), LogTypeInfo
CustomTSFilter = False
ElseIf ucase(oEnvironment.Item("ForceApplyFallback")) = "NEVER" and ucase(oUtility.SelectSingleNodeString(oOS, "IncludesSetup")) = "TRUE" then
oLogging.CreateEntry "Skip cross platform unattended install disabled (ForceApplyFallback = NEVER). " & oUtility.SelectSingleNodeString(oItem,"ID"), LogTypeInfo
CustomTSFilter = False
ElseIf oUtility.VersionMajor = 6 and oUtility.VersionMinor < 1 and ucase(oUtility.SelectSingleNodeString(oOS, "IncludesSetup")) = "TRUE" then
oLogging.CreateEntry "Skip cross platform unattended install for OS'es earlier than Windows 7. " & oUtility.SelectSingleNodeString(oItem,"ID"), LogTypeInfo
CustomTSFilter = False
ElseIf oEnv("SystemDrive") <> "X:" then
' We are not in WinPE, so we can still apply any OS
End if
End if
End if
If not oItem.selectSingleNode("SupportedPlatform") is nothing then
If not oUtility.IsSupportedPlatform(oUtility.SelectSingleNodeString(oItem,"SupportedPlatform")) then
oLogging.CreateEntry "Skip unsupported platform " & oUtility.SelectSingleNodeString(oItem,"SupportedPlatform") & " in " & oUtility.SelectSingleNodeString(oItem,"ID"), LogTypeVerbose
CustomTSFilter = False
Exit function
End if
End if
End function
Dim sCachedTSID
Dim oCachedTaskList
Function FindTaskSequenceStep(sStepType, sScriptCmd )
Dim oAction
Dim oItem
Dim oOptionDiableVal
' Is there a task sequence chosen yet? If not, the step can't possibly be present
If Property("TaskSequenceID") = "" then
oLogging.CreateEntry "No task sequence has been selected yet.", LogTypeVerbose
FindTaskSequenceStep = false
Exit Function
End if
' For efficiency, only load the task sequence if it has changed from the last time we loaded it
If sCachedTSID <> Property("TaskSequenceID") then
Set oCachedTaskList = oUtility.LoadConfigFileSafe( Property("TaskSequenceID") & "\TS.XML" )
sCachedTSID = Property("TaskSequenceID")
End if
' Get the list of nodes of the specified type
set oItem = oCachedTaskList.SelectNodes(sStepType)
If not oItem is nothing then
oLogging.CreateEntry "Found Task Sequence Item: " & sStepType, LogTypeInfo
ElseIf len(sScriptCmd) > 0 then
oLogging.CreateEntry "Unable to find Task Sequence step of type " & sStepType & ", performing more exhaustive search...", LogTypeInfo
For each oAction in oCachedTaskList.SelectNodes("//action")
If instr(1,oAction.XML,sScriptCmd,vbTExtCompare) <> 0 then
oLogging.CreateEntry "Found Task Sequence Item: " & sScriptCmd, LogTypeInfo
set oItem = oAction
exit for
End if
Next
End if
' Verify this step is not "disabled"...
If oItem is nothing then
oLogging.CreateEntry "Unable to find Task Sequence step of type " & sStepType , LogTypeInfo
FindTaskSequenceStep = False
Else
'Loop through each step in the collection until first enabled step and exit the loop
For each oOptionDiableVal in oItem
set oAction = oOptionDiableVal.Attributes.getNamedItem("disable")
If oAction is nothing then
FindTaskSequenceStep = true
Else
FindTaskSequenceStep = lcase(oAction.Value) <> "true"
If FindTaskSequenceStep = true then
Exit For
End If
End if
Next
oLogging.CreateEntry "Found Task Sequence step of type " & sStepType & " = " & FindTaskSequenceStep, LogTypeInfo
End if
End function