Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

818 lines
27 KiB

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <package>
  3. <job>
  4. <reference guid="{565783C6-CB41-11D1-8B02-00600806D9B6}" version="1.1"/>
  5. <resource id="query connections">SELECT * FROM Win32_NetworkConnection WHERE LOCALNAME IS NOT NULL</resource>
  6. <resource id="version">2.1</resource>
  7. <resource id="command line template"><![CDATA[%SOURCEPATH%\winnt32.exe /#t:4 /unattend:%TOOLSPATH%\%UNATTEND% /tempdrive:%_BLDDRIVE%]]></resource>
  8. <resource id="good options">
  9. EFI
  10. SAFE
  11. </resource>
  12. <comment>
  13. More restrictive filespec is possible
  14. </comment>
  15. <resource id="additional scripts">
  16. MD %_BLDDRIVE%\TOOLS
  17. XCOPY %TOOLDRIVE%\*.wsf %_BLDDRIVE%\TOOLS\
  18. XCOPY %TOOLDRIVE%\*.exe %_BLDDRIVE%\TOOLS\
  19. XCOPY %TOOLDRIVE%\*.cmd %_BLDDRIVE%\TOOLS\
  20. </resource>
  21. <resource id="keyfield">Boot entry ID</resource>
  22. <resource id="fieldlist">
  23. Boot entry ID
  24. OS Friendly Name
  25. Path
  26. OS Load Options
  27. </resource>
  28. <resource id="indexfield">
  29. OS Friendly Name
  30. </resource>
  31. <resource id="full description">
  32. <![CDATA[
  33. Version %VERSION%
  34. The script is executed by task scheduler:
  35. %SYSTEMDIR%\SYSTEM32\schtasks.exe /create /s &lt;TARGET COMPUTER&gt; /tn &lt;TASKID&gt; /u &lt;TARGET COMPUTER&gt;\&lt;TARGET USER&gt; /p &lt;PASSWORD&gt; /sc once /st &lt;TASK TIME&gt; /sd &lt;TASK DATE&gt;
  36. /tr "%SYSTEMDIR%\SYSTEM32\cmd.exe /C ...
  37. CSCRIPT.EXE &lt;NETWORK DRIVE&gt;\rx.wsf /from:&lt;MASTER COMPUTER&gt;\&lt;RELEASE SHARE&gt;"
  38. The &lt;MASTER COMPUTER&gt; and &lt;RELEASE SHARE&gt; are specified on the command line
  39. when executed as a scheduled task due to 255 characters scheduler command line length limitation.
  40. The rest of the parameters to determine the source build location is read from the registry:
  41. [HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\BOOTTEST]
  42. "_BuildArch"="x86"
  43. "_BuildType"="fre"
  44. "_BldSku"="SRV"
  45. "_BldName"="3615.x86fre.main.020306-1639"
  46. "_BldTools"="boottest.3615"
  47. "_BldDrive"="D"
  48. "Unattend"="unattend.txt"
  49. "LANG"="GER"
  50. "_BldNum"="3615"
  51. [HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\BOOTTEST\STATUS]
  52. "COMPUTERNAME"="BLD_WNXF1"
  53. The script wraps execution of:
  54. \\&lt;MASTER COMPUTER&gt;\&lt;RELEASE SHARE&gt;\&lt;LANG&gt;\&lt;BLDNAME&gt;\&lt;_BuildArch&gt;&lt;_BuildType&gt;\&lt;_BldSku&gt;\&lt;_ARCH&gt;\winnt32.exe
  55. The Status field is not used by the script yet.
  56. ]]>
  57. </resource>
  58. <runtime>
  59. <description>
  60. The script to wrap execution of:
  61. \\&lt;MASTER COMPUTER&gt;\&lt;RELEASE SHARE&gt;\&lt;LANG&gt;\&lt;BLDNAME&gt;\&lt;_BuildArch&gt;&lt;_BuildType&gt;\&lt;_BldSku&gt;\&lt;_ARCH&gt;\winnt32.exe
  62. No command line parameters but the &quot;from&quot; one need to be provided
  63. when executed as a scheduled task.
  64. </description>
  65. <named name="from" required="true" type="string"
  66. helpstring="the source share: \\&lt;MASTER COMPUTER&gt;\&lt;RELEASE SHARE&gt;">
  67. </named>
  68. <named name="drive" required="false" type="string"
  69. helpstring="target drive (REGISTRY: &lt;_BldDrive&gt;)">
  70. </named>
  71. <named name="path" required="false" type="string"
  72. helpstring="relative path to access the build residing on &lt;MASTER COMPUTER&gt;, &lt;RELEASE SHARE&gt; (REGISTRY: &lt;_BldName&gt;, &lt;_BldSku&gt;, &lt;_BuildType&gt;, &lt;_BuildArch&gt;, &lt;LANG&gt;)">
  73. </named>
  74. <named name="unattend" required="false" type="string"
  75. helpstring="build answer file (REGISTRY: &lt;Unattend&gt;)">
  76. </named>
  77. <named name="?" required="false" type="simple"
  78. helpstring="display help">
  79. </named>
  80. <named name="??" required="false" type="simple"
  81. helpstring="provide full help information">
  82. </named>
  83. </runtime>
  84. <comment>
  85. </comment>
  86. <resource id="step delay">30000</resource>
  87. <resource id="pipe delay">30</resource>
  88. <resource id="info fields">
  89. _BldDrive, _BuildArch, _BldSku, Unattend, SourcePath, LANG, ToolsPath
  90. </resource>
  91. <resource id="info key">HKEY_LOCAL_MACHINE\Software\MICROSOFT\BOOTTEST</resource>
  92. <script language="VBScript">
  93. <![CDATA[
  94. Sub pHeader(ipTextFile)
  95. Dim oArg
  96. ipTextFile.WriteLine _
  97. WScript.Name & _
  98. VBNEWLINE & _
  99. WScript.Application.FullName & _
  100. " " & _
  101. WScript.ScriptFullName
  102. ipTextFile.WriteLine _
  103. "Arguments:"
  104. For Each oArg in Wscript.arguments
  105. ipTextFile.WriteLine _
  106. oArg
  107. Next
  108. End Sub
  109. Sub SilentWaitP(isFullCommandLine)
  110. Dim opShell, intReturn
  111. Set opShell = WScript.CreateObject("WScript.Shell")
  112. intReturn = opShell.Run(isFullCommandLine, 1, TRUE)
  113. End Sub
  114. Sub DeleteOptions(aiSeHsh, aiFuHsh)
  115. '' Argument: list of options not to delete
  116. Dim oOtMp, opSeIdSz
  117. Dim spVaTe, npCnt, npCnIzS
  118. Dim opShell, opFilesys, spSampleCommand
  119. Set opSeIdSz = CreateObject("Scripting.Dictionary")
  120. npCnIzS = aiFuHsh.Count
  121. For each spDedId in aiSeHsh
  122. Set oOtMp = CreateObject("VBscript.RegExp")
  123. With oOtMp
  124. .Global = True
  125. .IgnoreCase = True
  126. .Pattern = "\"".*" & spDedId & ".*\"""
  127. End With
  128. For Each spVaTe in aiFuHsh.Keys
  129. If oOtMp.Test(spVaTe) Then
  130. If Debug Then
  131. WSCript.echo spDedId, spVaTe, cInt(aiFuHsh(spVaTe))
  132. End If
  133. aiFuHsh.Remove spVaTe
  134. End If
  135. Next
  136. Set oOtMp = Nothing
  137. Next
  138. Dim opSIetZs
  139. Set opSIetZs = CreateObject("Scripting.Dictionary")
  140. For Each spVaTe in aiFuHsh.Keys
  141. opSIetZs.Add CInt(aiFuHsh(spVaTe)), spVaTe
  142. Next
  143. spDedId = NULL
  144. For npCnt = 0 To npCnIzS + 1
  145. If isNULL(spDedId) Then
  146. If opSIetZs.Exists(npCnt) Then
  147. spDedId = CStr(npCnt)
  148. End If
  149. End If
  150. Next
  151. If Not isNull(spDedId) Then
  152. For Each spVaTe in aiFuHsh.Keys
  153. Set opShell = CreateObject("WScript.Shell")
  154. Set opFilesys = CreateObject("Scripting.FileSystemObject")
  155. spSampleCommand = opShell.ExpandEnvironmentStrings("%SYSTEMROOT%") & _
  156. "\SYSTEM32\bootcfg.exe" & _
  157. " /DELETE /ID:" & spDedId
  158. If Debug Then
  159. WSCript.echo spSampleCommand
  160. End If
  161. SilentWaitP(spSampleCommand )
  162. Next
  163. End If
  164. End Sub
  165. Sub DefaultOptions(aiSeHsh, aiFuHsh)
  166. '' Argument: list of options to put in default class
  167. '' Do it in minimal number of steps
  168. ''
  169. '' live without SORT !
  170. '' key-value stuff is reversed
  171. ''
  172. ''
  173. Dim oOtMp, opSeIdSz
  174. Dim spVaTe
  175. Dim opShell, opFilesys, spSampleCommand
  176. Set opSeIdSz = CreateObject("Scripting.Dictionary")
  177. For each spDedId in aiSeHsh
  178. Set oOtMp = CreateObject("VBscript.RegExp")
  179. With oOtMp
  180. .Global = True
  181. .IgnoreCase = True
  182. .Pattern = "\"".*" & spDedId& ".*\"""
  183. End With
  184. For Each spVaTe in aiFuHsh.Keys
  185. If oOtMp.Test(spVaTe) Then
  186. opSeIdSz.add cInt(aiFuHsh(spVaTe)), spDeMa
  187. If Debug Then
  188. WSCript.echo spDedId, spVaTe, cInt(aiFuHsh(spVaTe))
  189. End If
  190. End If
  191. Next
  192. Set oOtMp = Nothing
  193. Next
  194. _
  195. For npCnt = 0 to uBound(aiFuHsh.Keys) + 1
  196. If opSeIdSz.Exists(npCnt) Then
  197. spDedId = CStr(npCnt)
  198. Set opShell = CreateObject("WScript.Shell")
  199. Set opFilesys = CreateObject("Scripting.FileSystemObject")
  200. spSampleCommand = opShell.ExpandEnvironmentStrings("%SYSTEMROOT%") & _
  201. "\SYSTEM32\bootcfg.exe" & _
  202. " /DEFAULT /ID:" & spDedId
  203. If Debug Then
  204. WSCript.echo spSampleCommand
  205. End If
  206. SilentWaitP(spSampleCommand )
  207. End If
  208. Next
  209. Set opShell = Nothing
  210. Set opFilesys = Nothing
  211. End sub
  212. Function QueryOptions
  213. Dim aspOutPut, spOutPut, npLineCnt
  214. Dim asFieldList, nCnt, odFieldList, sField
  215. Dim spKeyField
  216. Dim oFieldXp
  217. Dim oFieldValueXp
  218. spKeyField = UCase(CStr(GetResource("keyfield")) & " ")
  219. asFieldList = ReadResource("fieldlist")
  220. Set odFieldList = CreateObject("Scripting.Dictionary")
  221. Dim odFieldValueDict
  222. Set odFieldValueDict = CreateObject("Scripting.Dictionary")
  223. Randomize
  224. For nCnt = 0 to UBound(asFieldList)
  225. sField = asFieldList(nCnt)
  226. Set oFieldXp = CreateObject("VBscript.RegExp")
  227. With oFieldXp
  228. .Global = True
  229. .IgnoreCase = True
  230. .Pattern = "^\s*" & sField & ".?\s?\s*"
  231. End With
  232. odFieldList.add oFieldXp, sField
  233. odFieldValueDict.add sField, oFieldXp
  234. Set oFieldXp = Nothing
  235. '' create keys but leave them undefined
  236. Next
  237. Dim spSampleCommand
  238. Dim opShell, opFilesys, sFolder, opTextFile
  239. Set opShell = CreateObject("WScript.Shell")
  240. Set opFilesys = CreateObject("Scripting.FileSystemObject")
  241. spSampleCommand = opShell.ExpandEnvironmentStrings("%SYSTEMROOT%") & _
  242. "\SYSTEM32\bootcfg.exe" & _
  243. " /QUERY"
  244. sFolder = opShell.ExpandEnvironmentStrings("%systemdrive%")
  245. Set opTextFile = opFilesys.CreateTextFile( sFolder & "\" & "test.txt", True)
  246. npDelay = CInt(GetResource("pipe delay"))
  247. aspOutput = WshPopen(spSampleCommand, NULL, -1 , npDelay)
  248. pHeader(opTextFile)
  249. For npLineCnt = 0 To UBound(aspOutPut)
  250. spOutPut = aspOutPut(npLineCnt)
  251. if Verbose Then
  252. WScript.echo spOutput
  253. End If
  254. opTextFile.WriteLine spOutput
  255. Next
  256. Dim sFoundLabel, sKnownTagKey, sPcontents, apQuoted, spBadQuotedPart, pbAddLine
  257. Dim aopStructuredOutput, npOptionCount
  258. npOptionCount = 0
  259. Dim pdThisElementData
  260. Set aopStructuredOutput = CreateObject("Scripting.Dictionary")
  261. For Each sKnownTagKey in odFieldList.keys
  262. If sKnownTagKey.Test(spKeyField) Then
  263. If Debug Then
  264. WScript.echo "identified" , sKnownTagKey.Pattern, spKeyField
  265. End If
  266. End If
  267. Next
  268. For npLineCnt = 0 To UBound(aspOutPut)
  269. sPcontents = aspOutPut(npLineCnt)
  270. sFoundLabel = ""
  271. For Each sKnownTagKey in odFieldList.keys
  272. If sKnownTagKey.Test(sPcontents) Then
  273. If sKnownTagKey.Test(spKeyField) Then
  274. npOptionCount = npOptionCount + 1
  275. If Debug Then
  276. WSCript.echo "npOptionCount=", npOptionCount
  277. End If
  278. aopStructuredOutput.add CStr(npOptionCount), ""
  279. End If
  280. Set apQuoted = sKnownTagKey.Execute(sPcontents)
  281. For each spBadQuotedPart in apQuoted
  282. sFoundLabel = CStr(Mid(sPcontents, _
  283. spBadQuotedPart.FirstIndex + _
  284. spBadQuotedPart.Length + 1 _
  285. ))
  286. Next
  287. If Debug Then
  288. WScript.echo sFoundLabel
  289. End If
  290. opTextFile.WriteLine sFoundLabel
  291. odFieldList(sKnownTagKey ) = sFoundLabel
  292. Set apQuoted = Nothing
  293. pbAddLine = True
  294. End If
  295. Next
  296. Set pdThisElementData = CreateObject("Scripting.Dictionary")
  297. For nCnt = 0 to UBound(asFieldList)
  298. sField = asFieldList(nCnt)
  299. pdThisElementData(sField) = odFieldList(odFieldValueDict(sField))
  300. Next
  301. If aopStructuredOutput.Exists(CStr(npOptionCount)) Then
  302. aopStructuredOutput.Remove( CStr(npOptionCount))
  303. End If
  304. aopStructuredOutput.add CStr(npOptionCount), pdThisElementData
  305. Next
  306. Dim opOne, odOne, spOne
  307. aopStructuredOutput.Remove("0")
  308. Dim opFilHa, osKyHa
  309. Set opFilHa = CreateObject("Scripting.Dictionary")
  310. osKyHa = ReadResource("indexfield")
  311. For Each opOne in aopStructuredOutput.keys
  312. If Debug Then
  313. WScript.echo chr(09) & "KEY: " & opOne , TypeName(aopStructuredOutput(opOne))
  314. End If
  315. Set odOne = aopStructuredOutput(opOne)
  316. For Each spOne in odOne.Keys
  317. If Verbose Then
  318. WScript.echo chr(09) & chr(09) & _
  319. """" & spOne & """", _
  320. ":" , odOne(spOne)
  321. End If
  322. Next
  323. Dim spRndName
  324. spRndName = Rnd
  325. spRndName = Mid(spRndName,3,5)
  326. opFilHa.add odOne(osKyHa) & " " & spRndName, opOne
  327. Next
  328. For Each opOne in opFilHa.Keys
  329. If Verbose Then
  330. WSCript.echo opOne, opFilHa(opOne)
  331. End If
  332. Next
  333. Set QueryOptions = opFilHa
  334. End Function
  335. ]]>
  336. </script>
  337. <script language="VBScript">
  338. <![CDATA[
  339. Function ReadResource(sPresId)
  340. On Error resume next
  341. Dim sPRes, asRes, uRes, tsRes
  342. Dim WshShell
  343. Set WshShell = CreateObject("WScript.Shell")
  344. sPREs = GetResource(sPresId)
  345. If Err.number <> 0 Then
  346. Wscript.echo err.number & " " & err.description
  347. ' The Error description are not informative when failed getresource
  348. IF Err.number = 7 Then
  349. Wscript.echo chr(9) & "Null resource: " & _
  350. sPresId
  351. End If
  352. IF Err.number = 5 Then
  353. Wscript.echo chr(9) & "Undefined resource: " & _
  354. sPresId
  355. End If
  356. Wscript.quit
  357. End If
  358. asRes = Split(WshShell.ExpandEnvironmentStrings(sPRes), VBNEWLINE)
  359. Set ures = CreateObject("Scripting.Dictionary")
  360. For Each tsRes in asRes
  361. If 0 <> Len(tsRes) Then
  362. uRes(tsRes) = 1
  363. End If
  364. Next
  365. Dim tResource
  366. tResource = uRes.Keys
  367. If uBound(tResource) = 0 Then
  368. ReadResource = tResource(0)
  369. Else
  370. ReadResource = tResource
  371. End If
  372. Set WshShell = Nothing
  373. Set uRes = Nothing
  374. End Function
  375. ]]>
  376. </script>
  377. <script language="VBScript">
  378. <![CDATA[
  379. Option Explicit
  380. Dim npDelay, Verbose, Debug
  381. Verbose = True
  382. Debug = True
  383. If WScript.Arguments.Length = 0 or _
  384. WSCript.Arguments.Named.Exists("?") or _
  385. NOT WSCript.Arguments.Named.Exists("from") _
  386. Then
  387. WSCript.Arguments.ShowUsage
  388. WScript.quit
  389. End If
  390. If WSCript.Arguments.Named.Exists("??") Then
  391. shoFullHelp("full description")
  392. WSCript.quit
  393. End If
  394. Dim oArg, spSku, spDrive
  395. Dim opShell, opFilesys, sFolder, opTextFile
  396. Set opShell = CreateObject("WScript.Shell")
  397. Set opFilesys = CreateObject("Scripting.FileSystemObject")
  398. Dim dpRegistryParam
  399. Set dpRegistryParam = CreateObject("Scripting.Dictionary")
  400. Dim spFieldList, spField
  401. Dim opTrm
  402. Set opTrm = CreateObject("VBscript.Regexp")
  403. With opTrm
  404. .Pattern="[,\s]"
  405. .Global=True
  406. End With
  407. For Each spFieldList in Split(GetResource("info fields"), VBNEWLINE)
  408. For Each spField in Split(spFieldList, ",")
  409. spField = opTrm.Replace(spField, "")
  410. spField = Ucase(spField)
  411. If "" <> spField Then
  412. dpRegistryParam.add spField, _
  413. opShell.RegRead (_
  414. CSTR(GetResource("info key")) & "\" & spField)
  415. If Verbose Then
  416. WScript.echo CSTR(GetResource("info key")) & _
  417. "\" & _
  418. spField & _
  419. "=>" & _
  420. dpRegistryParam.Item(spField)
  421. End If
  422. End If
  423. Next
  424. Next
  425. Dim spFromParam, dpFromParam
  426. '' dictionary reserved for the case /from:<DRIVE>: argument
  427. spFromParam = WScript.Arguments.Named("from")
  428. '' This stuff has been greately changed between 1.0 and 2.0
  429. Dim dpArchX
  430. Set dpArchX = CreateObject("Scripting.Dictionary")
  431. With dpArchX
  432. .add "X86" , "i386"
  433. .add "I386" , "i386"
  434. .add "IA64" , "ia64"
  435. End With
  436. dpRegistryParam("_BUILDARCH") = dpArchX(uCase(dpRegistryParam("_BUILDARCH")))
  437. _
  438. Dim spToolDrive, spScriptFullName
  439. spScriptFullName = WScript.ScriptFullName
  440. Dim opTDrvLx
  441. Set opTDrvLx = CreateObject("VBScript.RegExp")
  442. With opTDrvLx
  443. .Pattern = "(\w)\:\\.*$"
  444. .Global = True
  445. .IgnoreCase = True
  446. End With
  447. spToolDrive = opTDrvLx.Replace(spScriptFullName, "$1") & ":"
  448. on error goto 0
  449. Dim spCommand, spCommandTemplate
  450. ''spCommandTemplate = dpRegistryParam("SOURCEPATH") & _
  451. '' "\winnt32.exe /#t:4 /unattend:" & dpRegistryParam("TOOLSPATH") & _
  452. '' "\" & dpRegistryParam("UNATTEND") & " /tempdrive:" & dpRegistryParam("_BLDDRIVE")
  453. spCommandTemplate = GetResource("command line template")
  454. For Each spField in dpRegistryParam.Keys
  455. spCommandTemplate = Replace(spCommandTemplate, _
  456. "%" & spField & "%" , _
  457. dpRegistryParam(spField))
  458. Next
  459. Dim dpAllParameters, opRexF
  460. Set dpAllParameters = CreateObject("Scripting.Dictionary")
  461. spCommand = spCommandTemplate
  462. Dim opClnRx
  463. Set opClnRx = CreateObject("VBscript.RegExp")
  464. With opClnRx
  465. .Pattern = "\:\s*$"
  466. End With
  467. Dim spTempDrive
  468. spTempDrive = opClnRx.Replace(dpRegistryParam("_BLDDRIVE"),"")
  469. Dim spSource
  470. spSource = opClnRx.Replace(dpRegistryParam("SOURCEPATH"), "")
  471. For each spField in dpRegistryParam.Keys
  472. With dpAllParameters
  473. dpAllParameters.add "%" & spField & "%", dpRegistryParam.Item(spField)
  474. End with
  475. Next
  476. If Verbose Then
  477. For each spField in dpAllParameters.Keys
  478. WScript.echo spField , "=>", dpAllParameters.Item(spField)
  479. Next
  480. End If
  481. Set opClnRx = Nothing
  482. With dpAllParameters
  483. .add "%SHARE%" , spFromParam
  484. .add "%THREADS%" , 7
  485. .add("%TEMPDRIVE%") , spTempDrive
  486. .add("%TOOLDRIVE%") , dpRegistryParam("ToolsPath")
  487. .item("%UNATTEND%") = dpRegistryParam("ToolsPath") & "\" & dpRegistryParam("UNATTEND")
  488. End with
  489. For each spField in dpAllParameters.keys
  490. Set opRexf = CreateObject("VBscript.RegExp")
  491. opRexf.pattern = spField
  492. opRexf.global = True
  493. spCommand = opRexf.Replace(spCommand, dpAllParameters(spField))
  494. Set opRexf = Nothing
  495. Next
  496. spCommand = spCommandTemplate
  497. If Verbose Then
  498. call opShell.PopUp(spCommand, 60, "Test Build", 0 + 64)
  499. End If
  500. WScript.Sleep CInt(ReadResource("step delay"))
  501. opShell.RegWrite GetResource("info key") & "\STATUS\", ""
  502. opShell.RegWrite GetResource("info key") & "\STATUS\NOW" , "FORMAT RUNNING" , "REG_SZ"
  503. Dim spFormCommand
  504. spFormCommand = opShell.ExpandEnvironmentStrings("%SYSTEMROOT%") & "\SYSTEM32\format.com /X /Q /FS:NTFS " & dpRegistryParam("_BLDDRIVE")
  505. If Verbose Then
  506. call opShell.PopUp(spFormCommand, 3, "Test Build", 0 + 64)
  507. End If
  508. npDelay = CInt(GetResource("pipe delay"))
  509. call WshPopen(spFormCommand, "Y", 4, npDelay)
  510. opShell.RegWrite GetResource("info key") & "\STATUS\NOW" , "FORMAT COMPLETE" , "REG_SZ"
  511. Dim aAidCmds, spAidCmd
  512. aAidCmds = ReadResource("additional scripts")
  513. Dim opNetwork, opDrives, npCnt
  514. Set opTDrvLx = Nothing
  515. For Each spAidCmd in aAidCmds
  516. For each spField in dpAllParameters.keys
  517. Set opRexf = CreateObject("VBscript.RegExp")
  518. With opRexf
  519. .pattern = spField
  520. .global = True
  521. .ignorecase = True
  522. end with
  523. spAidCmd = opRexf.Replace(spAidCmd, dpAllParameters(spField))
  524. Set opRexf = Nothing
  525. Next
  526. WSCript.echo opShell.ExpandEnvironmentStrings("%COMSPEC%") & _
  527. " /C " & spAidCmd
  528. opshell.exec(opShell.ExpandEnvironmentStrings("%COMSPEC%") & _
  529. " /c " & spAidCmd)
  530. Next
  531. Dim aspGood: aspGood = ReadResource("good options")
  532. Dim opOpHast: Set opOpHast = QueryOptions
  533. For each spField in opOpHast.Keys
  534. WScript.echo spField
  535. Next
  536. Call DefaultOptions(aspGood, opOpHast)
  537. Set opOpHast = QueryOptions
  538. Call DeleteOptions(aspGood, opOpHast)
  539. Set opOpHast = QueryOptions
  540. aspGood = Array("SAFE")
  541. Call DefaultOptions(aspGood, opOpHast)
  542. Set opOpHast = QueryOptions
  543. WSCript.echo "1"
  544. For each spField in opOpHast.Keys
  545. WScript.echo spField
  546. Next
  547. WSCript.echo "2"
  548. WSCript.echo spCommand
  549. call opshell.run(spCommand)
  550. '' here one can wait + close the shares used...
  551. Set dpArchX = Nothing
  552. Set opShell = Nothing
  553. Set opFilesys = Nothing
  554. Set opTextFile = Nothing
  555. Set dpFromParam = Nothing
  556. Set dpRegistryParam = Nothing
  557. WSCript.quit(0)
  558. Function WshPopen(isFullCommandLine, siAnswer, niCnt, niDelay )
  559. '' provide the pipeline with the process to execute
  560. Dim spFullOutput, spOutPut
  561. Dim opShell, opExec
  562. Dim npCnt
  563. npCnt = 0
  564. Set opShell = WScript.CreateObject("WScript.Shell")
  565. Set opExec = opShell.Exec(isFullCommandLine)
  566. If Verbose Then
  567. WSCript.echo isFullCommandLine
  568. End If
  569. spOutput = ""
  570. Do While True
  571. spOutPut = ReadAllFromAny(opExec)
  572. If isNull(spOutPut) Then
  573. Exit Do
  574. End If
  575. If npCnt = niCnt Then
  576. opExec.StdIn.Write siAnswer & VBNEWLINE
  577. Wscript.echo spOutput , _
  578. siAnswer
  579. Else
  580. on error resume next
  581. opExec.StdIn.Write VBNEWLINE
  582. on error goto 0
  583. spFullOutput = spFullOutput & VBNEWLINE & spOutPut
  584. End If
  585. WScript.Sleep niDelay
  586. npCnt = 1 + npCnt
  587. Loop
  588. Const WshRunning = 0
  589. Do while opExec.Status = CInt(WshRunning)
  590. WScript.Sleep 100
  591. Loop
  592. If Verbose Then
  593. Wscript.echo spFullOutput & VBNEWLINE
  594. End If
  595. WshPopen = Split(spFullOutput, VBNEWLINE)
  596. End Function
  597. Function ReadAllFromAny(oExec)
  598. '' reads from STDERR and STDOUT
  599. If Not oExec.StdOut.AtEndOfStream Then
  600. ReadAllFromAny = oExec.StdOut.ReadLine
  601. If Verbose Then
  602. WSCript.echo ReadAllFromAny & "(1)"
  603. End If
  604. Exit Function
  605. End If
  606. If Not oExec.StdErr.AtEndOfStream Then
  607. ReadAllFromAny = oExec.StdErr.ReadLine
  608. If Verbose Then
  609. WSCript.echo ReadAllFromAny & "(2)"
  610. End If
  611. Exit Function
  612. End If
  613. ReadAllFromAny = NULL
  614. End Function
  615. _
  616. _
  617. Function spConnectionRemoteName(siConnectionLocalName)
  618. '' returns the UNC path for the given remote connection
  619. '' supplier
  620. Dim opDriveRx, opNtWrk, spTargetComputer, opaDvi, npCnt, opWBEMClass, opWBEMProvider, opConn, aopConnectionSet
  621. Set opDriveRx = CreateObject("VBscript.RegExp")
  622. With opDriveRx
  623. .Pattern = siConnectionLocalName
  624. .Ignorecase = True
  625. End With
  626. spConnectionRemoteName = NULL
  627. Set opNtWrk = WScript.CreateObject("WScript.Network")
  628. Set opaDvi = opNtWrk.EnumNetworkDrives
  629. For npCnt = 0 to opaDvi.Count -1
  630. If opDriveRx.Test(opaDvi.Item(npCnt)) Then
  631. spConnectionRemoteName = opaDvi.Item(npCnt)
  632. End If
  633. Next
  634. If Not IsNull(spConnectionRemoteName) then
  635. Err.Clear
  636. Set opWBEMClass = CreateObject("WbemScripting.SWbemLocator")
  637. opWBEMClass.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
  638. opWBEMClass.Security_.Privileges.AddAsString("SeRemoteShutdownPrivilege")
  639. opWBEMClass.Security_.Privileges.AddAsString("SeShutdownPrivilege")
  640. opWBEMClass.Security_.Privileges.AddAsString("SeSystemEnvironmentPrivilege")
  641. spTargetComputer = opNtWrk.computername
  642. Set opWBEMProvider = opWBEMClass.ConnectServer(spTargetComputer, "root\cimV2")
  643. Set aopConnectionSet = opWBEMProvider._
  644. ExecQuery(getResource("query connections"))
  645. for each opConn in aopConnectionSet
  646. If opDriveRx.Test(opConn.LocalName) Then
  647. spConnectionRemoteName = opConn.RemoteName
  648. End If
  649. next
  650. End If
  651. Set opDriveRx = Nothing
  652. Set opNtWrk = Nothing
  653. Set aopConnectionSet = Nothing
  654. End Function
  655. sub shoFullHelp(siTag)
  656. Const VBEXPECTED = 5
  657. on error resume next
  658. Dim oGeRpVl
  659. Dim oGeRpNeA
  660. Dim oHtXtExL
  661. Dim odHxTaGp
  662. Dim aoRplaceMatches, oMatch, sMatch, sLabel, sResource
  663. Set odHxTaGp = CreateObject("Scripting.Dictionary")
  664. With odHxTaGp
  665. .add "&lt;" , "<"
  666. .add "&gt;" , ">"
  667. .add "&amp;", "&"
  668. End With
  669. Set oGeRpVl = CreateObject("VBscript.RegExp")
  670. Set oGeRpNeA = CreateObject("VBscript.RegExp")
  671. With oGeRpVl
  672. .Global = True
  673. .IgnoreCase = True
  674. .Pattern = "%\w+%"
  675. End With
  676. With oGeRpNeA
  677. .Global = True
  678. .IgnoreCase = True
  679. .Pattern = "%\w+%"
  680. End With
  681. Dim sLine,asTest
  682. asTest = ReadResource(siTag)
  683. For Each sLine in asTest
  684. Set aoRplaceMatches = oGeRpVl.Execute(sLine)
  685. For Each oMatch in aoRplaceMatches
  686. sMatch = oMatch.value
  687. sMatch = UCase(Mid(sMatch, 2, Len(sMatch)-2))
  688. sLabel = LCase(sMatch)
  689. Err.clear
  690. sResource = GetResource(sLabel)
  691. If err = 0 Then
  692. sMatch = sResource
  693. ElseIf err = VBEXPECTED Then
  694. sMatch = "<" & sMatch & ">"
  695. Else
  696. Raise Err
  697. End If
  698. oGeRpNeA.Pattern = oMatch.value
  699. sLine = oGeRpNeA.Replace(sLine, sMatch)
  700. Next
  701. Dim spHxTgZ
  702. For each spHxTgZ in odHxTaGp.Keys
  703. Set oHtXtExl = CreateObject("VBscript.RegExp")
  704. With oHtXtExl
  705. .pattern = spHxTgZ
  706. .Global = True
  707. .IgnoreCase = True
  708. End With
  709. sLine = oHtXtExL.Replace(sLine, odHxTaGp(spHxTgZ))
  710. Set oHtXtExl = Nothing
  711. Next
  712. WScript.echo sLine
  713. Next
  714. Set oGeRpVl = Nothing
  715. Set oGeRpNeA = Nothing
  716. End sub
  717. ]]>
  718. </script>
  719. </job>
  720. </package>