Guest User

DeployWiz_SelectTS - Select by TaskSequence

a guest
Jun 10th, 2018
3,441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.90 KB | None | 0 0
  1. ' // ***************************************************************************
  2. ' //
  3. ' // Copyright (c) Microsoft Corporation. All rights reserved.
  4. ' //
  5. ' // Microsoft Deployment Toolkit Solution Accelerator
  6. ' //
  7. ' // File: DeployWiz_Initialization.vbs
  8. ' //
  9. ' // Version: 6.3.8330.1000 ** copied to 8450 ** jerry*** Special version supports select by task ID
  10. ' //
  11. ' // Purpose: Main Client Deployment Wizard Initialization routines
  12. ' //
  13. ' // ***************************************************************************
  14.  
  15.  
  16. Option Explicit
  17.  
  18.  
  19. '''''''''''''''''''''''''''''''''''''
  20. ' Image List
  21. '
  22.  
  23. Dim g_AllOperatingSystems
  24.  
  25. Function AllOperatingSystems
  26.  
  27.  
  28. Dim oOSes
  29.  
  30. If isempty(g_AllOperatingSystems) then
  31.  
  32. set oOSes = new ConfigFile
  33. oOSes.sFileType = "OperatingSystems"
  34. oOSes.bMustSucceed = false
  35.  
  36. set g_AllOperatingSystems = oOSes.FindAllItems
  37.  
  38. End if
  39.  
  40. set AllOperatingSystems = g_AllOperatingSystems
  41.  
  42. End function
  43.  
  44.  
  45. Function InitializeTSList
  46. Dim oItem, sXPathOld
  47.  
  48. If oEnvironment.Item("TaskSequenceID") <> "" and oProperties("TSGuid") = "" then
  49.  
  50. sXPathOld = oTaskSequences.xPathFilter
  51. for each oItem in oTaskSequences.oControlFile.SelectNodes( "/*/*[ID = '" & oEnvironment.Item("TaskSequenceID")&"']")
  52. oLogging.CreateEntry "TSGuid changed via TaskSequenceID = " & oEnvironment.Item("TaskSequenceID"), LogTypeInfo
  53. oEnvironment.Item("TSGuid") = oItem.Attributes.getNamedItem("guid").value
  54. exit for
  55. next
  56.  
  57. oTaskSequences.xPathFilter = sXPathOld
  58.  
  59. End if
  60.  
  61. TSListBox.InnerHTML = oTaskSequences.GetHTMLEx ( "Radio", "TSGuid" )
  62.  
  63. PopulateElements
  64. TSItemChange
  65.  
  66. End function
  67.  
  68.  
  69. Function TSItemChange
  70.  
  71. Dim oInput
  72. ButtonNext.Disabled = TRUE
  73.  
  74. for each oInput in document.getElementsByName("TSGuid")
  75. If oInput.Checked then
  76. oLogging.CreateEntry "Found CHecked Item: " & oInput.Value, LogTypeVerbose
  77.  
  78. ButtonNext.Disabled = FALSE
  79. exit function
  80. End if
  81. next
  82.  
  83. End function
  84.  
  85.  
  86. '''''''''''''''''''''''''''''''''''''
  87. ' Validate task sequence List
  88. '
  89.  
  90. Function ValidateTSList
  91.  
  92. Dim oTaskList
  93. Dim oTS
  94. Dim oItem
  95. Dim oOSItem
  96. Dim sID
  97. Dim bFound
  98. Dim sTemplate
  99. Dim oTaskOsUpgrade
  100.  
  101. ' Patch - part 1 of 2 added by Jerry
  102. Dim sCmd
  103. Set Oshell = createObject("Wscript.shell")
  104.  
  105. set oTS = new ConfigFile
  106. oTS.sFileType = "TaskSequences"
  107.  
  108. SaveAllDataElements
  109.  
  110. If Property("TSGuid") = "" then
  111. oLogging.CreateEntry "No valid TSGuid found in the environment.", LogTypeWarning
  112. ValidateTSList = false
  113. End if
  114.  
  115. oLogging.CreateEntry "TSGuid Found: " & Property("TSGuid"), LogTypeVerbose
  116.  
  117. sID = ""
  118. sTemplate = ""
  119. If oTS.FindAllItems.Exists(Property("TSGuid")) then
  120. sID = oUtility.SelectSingleNodeString(oTS.FindAllItems.Item(Property("TSGuid")),"./ID")
  121. sTemplate = oUtility.SelectSingleNodeString(oTS.FindAllItems.Item(Property("TSGuid")),"./TaskSequenceTemplate")
  122. End if
  123.  
  124. oEnvironment.item("TaskSequenceID") = sID
  125. TestAndLog sID <> "", "Verify Task Sequence ID: " & sID
  126. Set oTaskList = oUtility.LoadConfigFileSafe( sID & "\TS.XML" )
  127.  
  128. If not FindTaskSequenceStep( "//step[@type='BDD_InstallOS']", "" ) and not FindTaskSequenceStep( "//step[@type='BDD_UpgradeOS']", "" ) then
  129.  
  130. oLogging.CreateEntry "Task Sequence does not contain an OS and does not contain a LTIApply.wsf step, possibly a Custom Step or a Client Replace.", LogTypeInfo
  131.  
  132. oProperties.Item("OSGUID")=""
  133. If not (oTaskList.SelectSingleNode("//group[@name='State Restore']") is nothing) then
  134. oProperties("DeploymentType") = "StateRestore"
  135. ElseIf sTemplate <> "ClientReplace.xml" and oTaskList.SelectSingleNode("//step[@name='Capture User State']") is nothing then
  136. oProperties("DeploymentType")="CUSTOM"
  137. Else
  138. oProperties("DeploymentType")="REPLACE"
  139.  
  140. RMPropIfFound("ImageIndex")
  141. RMPropIfFound("ImageSize")
  142. RMPRopIfFound("ImageFlags")
  143. RMPropIfFound("ImageBuild")
  144. RMPropIfFound("InstallFromPath")
  145. RMPropIfFound("ImageMemory")
  146.  
  147. oEnvironment.Item("ImageProcessor")=Ucase(oEnvironment.Item("Architecture"))
  148. End if
  149.  
  150. Elseif oEnvironment.Item("OSVERSION")="WinPE" Then
  151.  
  152. oProperties("DeploymentType")="NEWCOMPUTER"
  153.  
  154. Else
  155.  
  156. oLogging.CreateEntry "Task Sequence contains a LTIApply.wsf step, and is not running within WinPE.", LogTypeInfo
  157. Set oTaskOsUpgrade = oTaskList.SelectSingleNode("//globalVarList/variable[@name='IsOSUpgrade']")
  158. If oTaskOsUpgrade is Nothing then
  159. oProperties("DeploymentType") = "REFRESH"
  160. Else
  161. oProperties("DeploymentType") = "UPGRADE"
  162. End if
  163. oEnvironment.Item("DeployTemplate")=Ucase(Left(sTemplate,Instr(sTemplate,".")-1))
  164.  
  165.  
  166. End if
  167.  
  168. oLogging.CreateEntry "DeploymentType = " & oProperties("DeploymentType"), LogTypeInfo
  169. oEnvironment.Item("DeploymentType") = oProperties("DeploymentType")
  170. If oEnvironment.Item("DeploymentType") <> "" and oEnvironment.Item("DeploymentType") = "UPGRADE" then
  171. oLogging.CreateEntry "Upgrade Task Sequence is selected, setting Environment var IsOSUpgrade = 1", LogTypeInfo
  172. oEnvironment.Item("IsOSUpgrade") = "1"
  173. Else
  174. oLogging.CreateEntry "NON-OS Upgrade Task Sequence is selected, setting Environment var IsOSUpgrade = 0", LogTypeInfo
  175. oEnvironment.Item("IsOSUpgrade") = "0"
  176. End if
  177.  
  178.  
  179. set oTaskList = nothing
  180. set oTS = nothing
  181.  
  182.  
  183. ' Set the related properties
  184.  
  185. oEnvironment.Item("ImageProcessor") = ""
  186. oEnvironment.Item("OSGUID")=""
  187. oUtility.SetTaskSequenceProperties sID
  188.  
  189. If ucase(oProperties("DeploymentType"))="NEWCOMPUTER" then
  190. oUtility.GetMajorMinorVersion(oEnvironment.Item("ImageBuild"))
  191. If oUtility.VersionMajor >= 10 then
  192. oProperties("OSDDiskPartitionStyle")="WIN10ADVANCED"
  193. Else
  194. oProperties("OSDDiskPartitionStyle")="PREWIN10"
  195. End if
  196. End if
  197.  
  198. oUtility.GetMajorMinorVersion(Property("ImageBuild"))
  199. If oUtility.VersionMajor < 6 then
  200. RMPropIfFound("LanguagePacks")
  201. RMPropIfFound("UserLocaleAndLang")
  202. RMPropIfFound("KeyboardLocale")
  203. RMPropIfFound("UserLocale")
  204. RMPropIfFound("UILanguage")
  205. RMPropIfFound("BdePin")
  206. RMPropIfFound("BdeModeSelect1")
  207. RMPropIfFound("BdeModeSelect2")
  208. RMPropIfFound("OSDBitLockerStartupKeyDrive")
  209. RMPropIfFound("WaitForEncryption")
  210. RMPropIfFound("BdeInstall")
  211. RMPropIfFound("OSDBitLockerWaitForEncryption")
  212. RMPropIfFound("BdeRecoveryKey")
  213. RMPropIfFound("BdeInstallSuppress")
  214. End If
  215.  
  216. If oEnvironment.Item("OSGUID") <> "" and oEnvironment.Item("ImageProcessor") = "" then
  217. ' There was an OSGUID defined within the TS.xml file, however the GUID was not found
  218. ' within the OperatingSystems.xml file. Which is a dependency error. Block the wizard.
  219. ValidateTSList = False
  220. ButtonNext.Disabled = True
  221. Bad_OSGUID.style.display = "inline"
  222. Else
  223. ValidateTSList = True
  224. ButtonNext.Disabled = False
  225. Bad_OSGUID.style.display = "none"
  226. ENd if
  227.  
  228. ' Patch 2 of 2 added by Jerry
  229. sCmd = "wscript.exe """ & oUtility.ScriptDir & "\ZTIGather.wsf"""
  230. oItem = oSHell.Run(sCmd, , true)
  231.  
  232. End Function
Advertisement
Add Comment
Please, Sign In to add comment