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.

757 lines
25 KiB

  1. '*************************************************************************************
  2. '*
  3. '* VDS BVT (Smoke) Test
  4. '*
  5. '*************************************************************************************
  6. 'on Error resume Next
  7. 'defining constants
  8. dim strNamespace, strHost
  9. dim tempVolume 'used to pick a volume for test purposes
  10. dim tempPath 'used to create a path on the above volume for mounting
  11. dim objReportPostFrag
  12. dim objReportPostDeFrag
  13. dim fso
  14. dim strFragCmd, strValpropCmd
  15. tempDirPrefix = "Win32_Directory.Name="""
  16. tempQuote=""""
  17. srcFolder = "temp"
  18. mountDir = "mnt"
  19. strFragCmd = "..\bin\i386\frag.exe -r -f20 "
  20. strValPropCmd = "..\bin\i386\valprop.exe 1 "
  21. Set fso = CreateObject("Scripting.FileSystemObject")
  22. 'Parse Command Line
  23. If Wscript.Arguments.Count <> 2 Then
  24. Wscript.Echo("Invalid Syntax:")
  25. Wscript.Echo("")
  26. Wscript.Echo("vds.vbs <host|.> <volumePath>")
  27. Wscript.quit
  28. End If
  29. 'do groundwork to set log file
  30. logFileName = "log_vdsBVT.txt"
  31. Set fso = CreateObject("Scripting.FileSystemObject")
  32. result = fso.FileExists(logFileName)
  33. if (result = true) then
  34. fso.DeleteFile(logFileName)
  35. end if
  36. set f = fso.CreateTextFile(logFileName)
  37. 'extract command line arguments
  38. strHost = wscript.Arguments(0)
  39. strNamespace = "winmgmts://" & wscript.Arguments(0) & "/root/cimv2"
  40. strVolume = wscript.Arguments(1)
  41. strVolume = Replace (strVolume, "\", "\\")
  42. 'get the volume
  43. strQuery = "select * from Win32_Volume where Name = '" & strVolume & "'"
  44. set VolumeSet = GetObject(strNamespace).ExecQuery(strQuery)
  45. for each obj in VolumeSet
  46. set Volume = obj
  47. exit for
  48. next
  49. Call CheckFileSystem ()
  50. wscript.echo ("----------------------------------------")
  51. Call DriveLetterTest ()
  52. wscript.echo ("----------------------------------------")
  53. if strHost = "." then
  54. Call CopyFilesToVolume ()
  55. wscript.echo ("----------------------------------------")
  56. Call FragVolume ()
  57. wscript.echo ("----------------------------------------")
  58. else
  59. call WriteLog(" REMOTE - skipping volume fragmentation")
  60. end if
  61. Call DefragAnalysis ()
  62. wscript.echo ("----------------------------------------")
  63. Call ListFragmentation (objReportPostFrag)
  64. wscript.echo ("----------------------------------------")
  65. Call DefragVolume ()
  66. wscript.echo ("----------------------------------------")
  67. Call ListFragmentation (objReportPostDeFrag)
  68. wscript.echo ("----------------------------------------")
  69. Call DoMountingTests ()
  70. wscript.echo ("----------------------------------------")
  71. Call DoDiskServices ()
  72. wscript.echo ("----------------------------------------")
  73. Call RWPropertyChanger ()
  74. wscript.echo ("----------------------------------------")
  75. if strHost = "." then
  76. Call ValidateAllProperties()
  77. wscript.echo ("----------------------------------------")
  78. else
  79. call WriteLog(" REMOTE - skipping full property validation")
  80. end if
  81. call DisplaySummary()
  82. '**********************************************************
  83. function DriveLetterTest()
  84. on error resume next
  85. DIM strDriveLetter, strDrivePath
  86. DIM objNewSet
  87. strDriveLetter = "J:"
  88. strDrivePath = strDriveLetter & "\"
  89. if (isNull (volume.driveletter) ) then
  90. wscript.echo ("Assigning drive letter to volume")
  91. volume.DriveLetter = strDriveLetter
  92. volume.Put_
  93. rc = ReportIfErr(Err, " FAILED - volume (driveLetter) Put operation failed")
  94. Result = volume.AddMountPoint(strDrivePath)
  95. rc = ReportIfErr(Err, " FAILED - AddMountPoint")
  96. call WriteLog (" addmountpoint error code message = " & MapErrorCode("Win32_Volume", "AddMountPoint", Result))
  97. strQuery = "select * from Win32_Volume where Name = '" & strDrivePath & "\'"
  98. set objNewSet = GetObject(strNamespace).ExecQuery(strQuery)
  99. rc = ReportIfErr(Err, " FAILED - volume query failed")
  100. if objNewSet.Count < 1 then
  101. call WriteLog (" FAILED - unable to find volume by newly assigned drive letter : " & strDriveLetter)
  102. end if
  103. end if
  104. Err.Clear
  105. set volume = RefreshObject(volume)
  106. end function
  107. '**********************************************************
  108. Function CheckFileSystem ()
  109. on error resume next
  110. 'checking filesystem
  111. wscript.echo ("File System Checks")
  112. if (IsNull(volume.FileSystem)) then
  113. wscript.echo (" volume needs formatting .. now formatting ...")
  114. Result = volume.Format()
  115. rc = ReportIfErr(Err, "FAILED - volume Format method failed")
  116. if (Result = 0 AND rc = 0) then
  117. call WriteLog(" success - format")
  118. else
  119. call WriteLog (" FAILED - format result : " & Result & " : " & MapErrorCode("Win32_Volume", "Format", Result))
  120. call WriteLog(" FAILED - bailing out")
  121. wscript.quit
  122. end if
  123. else
  124. call WriteLog (" disk does not require formatting; file system = "&volume.FileSystem)
  125. end if
  126. end Function
  127. '**********************************************************
  128. Function CopyFilesToVolume ()
  129. 'copyfiles to volume
  130. wscript.echo("")
  131. wscript.echo("Copying Temp Files")
  132. fso.CopyFile "c:\windows\system32\wbem\*.*", volume.Name
  133. call WriteLog (" success - file copy")
  134. end Function
  135. '**********************************************************
  136. Function FragVolume ()
  137. wscript.echo ("")
  138. wscript.echo ("Fragmentation")
  139. wscript.echo(" fragmenting the volume to which the above files were copied to")
  140. wscript.echo(" please wait since this can take a while ....")
  141. DIM objShell, objExec
  142. DIM output
  143. Set objShell = CreateObject("WScript.Shell")
  144. Set objExec = objShell.Exec(strFragCmd & volume.Name)
  145. Do While objExec.Status = 0
  146. 'WScript.Echo "Exec.Status: " & objExec.Status
  147. WScript.Sleep 100
  148. If Not objExec.StdOut.AtEndOfStream Then
  149. objExec.StdOut.ReadAll
  150. End If
  151. Loop
  152. end Function
  153. function DefragAnalysis()
  154. call WriteLog(" success - fragmentation")
  155. wscript.echo(" saving disk analysis report")
  156. ResultPostFrag = volume.DefragAnalysis(fRecommended, objReportPostFrag)
  157. strMessage = MapErrorCode("Win32_volume", "DefragAnalysis", ResultPostFrag)
  158. call WriteLog (" defrag error code message = "& strMessage)
  159. end function
  160. '**********************************************************
  161. Function DefragVolume ()
  162. on error resume next
  163. wscript.echo("")
  164. wscript.echo("Degrag Tests and Analysis")
  165. wscript.echo(" doing defrag on the volume and saving defrag report")
  166. fForce = True
  167. ResultOfDefrag = volume.Defrag(fForce, objReportPostDefrag)
  168. rc = ReportIfErr(Err, "FAILED - volume Defrag method failed")
  169. strMessage = MapErrorCode("Win32_volume", "Defrag", ResultOfDefrag)
  170. call WriteLog (" defrag error code message = "& strMessage)
  171. end Function
  172. '**********************************************************
  173. Function DoMountingTests()
  174. on error resume next
  175. wscript.echo ("")
  176. wscript.echo ("Mounting Tests")
  177. wscript.echo(" selecting volume with windows on it ... ")
  178. Set objSet = GetObject(strNamespace).InstancesOf("Win32_Volume")
  179. rc = ReportIfErr(Err, " FAILED - volume enumeration failed")
  180. for each obj in objSet
  181. result = fso.FolderExists(obj.DriveLetter&"\WINDOWS")
  182. if ( result = true ) then
  183. set tempVolume = obj
  184. wscript.echo (" picking "&obj.DriveLetter)
  185. exit for
  186. end if
  187. next
  188. if (result = false) then
  189. call WriteLog (" FAILED - Could not attain tempVolume ... bailing out ..")
  190. wscript.quit
  191. end if
  192. result = fso.FolderExists(tempVolume.DriveLetter&"\"&mountDir)
  193. if (result = true) then
  194. wscript.echo(" folder called "&mountDir&" already exsits")
  195. else
  196. wscript.echo(" creating directory on tempVolume called "&mountDir)
  197. fso.CreateFolder(tempVolume.DriveLetter&"\"&mountDir)
  198. result = fso.FolderExists(tempVolume.DriveLetter&"\"&mountDir)
  199. if (result = true) then
  200. wscript.echo (" folder created")
  201. wscript.echo ("")
  202. else
  203. call WriteLog (" FAILED - folder creation failed .. exiting monting tests ... ")
  204. exit Function
  205. end if
  206. end if
  207. tempPath = tempVolume.DriveLetter&"\"&mountDir&"\"
  208. tempDir = tempDirPrefix&tempVolume.DriveLetter&"\\"&mountDir&tempQuote
  209. wscript.echo (" mounting the volume to the above directory, which is = "&tempPath)
  210. result = volume.AddMountPoint(tempPath)
  211. rc = ReportIfErr(Err, "FAILED - volume addmountpoint method failed")
  212. if (result = 0) then
  213. call WriteLog (" success - mounting")
  214. wscript.echo("")
  215. strMessage = MapErrorCode("Win32_volume", "AddMountPoint", result)
  216. call WriteLog (" mounting error code message = "& strMessage)
  217. else
  218. strMessage = MapErrorCode("Win32_volume", "AddMountPoint", result)
  219. call WriteLog (" mounting error code message = "& strMessage)
  220. call WriteLog (" FAILED - mounting, exiting mounting tests")
  221. exit Function
  222. end if
  223. wscript.echo(" validating mountpoint exists through WMI query")
  224. set objSet = volume.Associators_("Win32_MountPoint")
  225. rc = ReportIfErr(Err, " FAILED - volume associators operation failed")
  226. if (objSet.Count < 1) then
  227. call WriteLog(" FAILED - volume associators for known mountpont failed")
  228. end if
  229. found = FALSE
  230. tempCompareName = LCase(tempVolume.DriveLetter)&"\"&mountDir
  231. for each obj in objSet
  232. if ( tempCompareName = obj.Name) then
  233. call WriteLog (" success - validation through WMI query")
  234. found = TRUE
  235. exit for
  236. end if
  237. next
  238. if (found = FALSE) then
  239. call WriteLog (" FAILED - validation through WMI query")
  240. end if
  241. wscript.echo(" dismounting V1 with permanent option")
  242. bPermanent=TRUE
  243. Result = Volume.Dismount(True, bPermanent)
  244. rc = ReportIfErr(Err, " FAILED - volume Dismount method failed")
  245. wscript.echo (" Volume.Dismount returned: " & Result)
  246. strMessage = MapErrorCode("Win32_volume", "Dismount", Result)
  247. call WriteLog (" dismounting (with perm options) error code message = "& strMessage)
  248. wscript.echo("")
  249. 'Call ListAllMountPoints()
  250. wscript.echo("")
  251. wscript.echo(" deleting mountpoint "&tempDir)
  252. Set objSet = GetObject(strNamespace).InstancesOf("Win32_MountPoint")
  253. rc = ReportIfErr(Err, " FAILED - mountpoint enumeration failed")
  254. for each Mount in objSet
  255. if (tempDir = Mount.Directory) then
  256. wscript.echo (" calling Mount.Delete_")
  257. Mount.Delete_
  258. rc = ReportIfErr(Err, " FAILED - mountpoint delete failed")
  259. exit for
  260. end if
  261. next
  262. 'Call ListAllMountPoints()
  263. wscript.echo("")
  264. Set objSet = GetObject(strNamespace).InstancesOf("Win32_MountPoint")
  265. for each Mount in objSet
  266. if (tempDir = Mount.Directory) then
  267. call WriteLog (" FAILED - mountpoint deletion")
  268. exit function
  269. end if
  270. next
  271. call WriteLog(" success - mountpoint deletion")
  272. end Function
  273. '**********************************************************
  274. Function ListAllMountPoints ()
  275. wscript.echo("")
  276. wscript.echo(" listing instances of all mountpoints")
  277. Set objSet = GetObject(strNamespace).InstancesOf("Win32_MountPoint")
  278. rc = ReportIfErr(Err, " FAILED - mountpoint enumeration failed")
  279. for each Mount in objSet
  280. WScript.Echo " "&Mount.Volume
  281. wscript.echo " "&Mount.Directory
  282. next
  283. End Function 'end of ListAllMountPoints
  284. '**********************************************************
  285. Function DoDiskServices ()
  286. on error resume next
  287. wscript.echo("")
  288. wscript.echo("Disk Services")
  289. wscript.echo (" scheduling autochk")
  290. dim astrVol(0)
  291. astrvol(0) = volume.DriveLetter
  292. Result = volume.ScheduleAutoChk(astrvol)
  293. rc = ReportIfErr(Err, " FAILED - volume scheduleautochk method failed")
  294. if (Result = 0) then
  295. wscript.echo " volume.ScheduleAutoChk returned no error"
  296. wscript.echo("")
  297. else
  298. wscript.echo " volume.ScheduleAutoChk returned error code = " & Result
  299. end if
  300. strMessage = MapErrorCode("Win32_volume", "ScheduleAutoChk", Result)
  301. call WriteLog (" ScheduleAutoChk error code message = "& strMessage)
  302. wscript.echo("")
  303. wscript.echo (" excluding autochk")
  304. Result = volume.ExcludeFromAutoChk(astrvol)
  305. rc = ReportIfErr(Err, " FAILED - volume excludefromautochk method failed")
  306. if (Result = 0) then
  307. wscript.echo " volume.ExcludeAutoChk returned no error"
  308. wscript.echo("")
  309. else
  310. wscript.echo " volume.ExcludeAutoChk returned error code = " & Result
  311. end if
  312. strMessage = MapErrorCode("Win32_volume", "ExcludeFromAutoChk", Result)
  313. call WriteLog (" ExcludeAutoChk error code message = "& strMessage)
  314. wscript.echo ("")
  315. wscript.echo (" running - fsutil dirty set volume.driveletter")
  316. DIM objShell, objExec
  317. DIM output
  318. if strHost = "." then
  319. Set objShell = CreateObject("WScript.Shell")
  320. Set objExec = objShell.Exec("fsutil dirty set "&volume.DriveLetter)
  321. Do While objExec.Status = 0
  322. 'WScript.Echo "Exec.Status: " & objExec.Status
  323. WScript.Sleep 100
  324. If Not objExec.StdOut.AtEndOfStream Then
  325. wscript.echo (objExec.StdOut.ReadAll)
  326. End If
  327. Loop
  328. set volume = RefreshObject(volume)
  329. wscript.echo ("")
  330. wscript.echo ("checking if diry bit set (success) or not (failure)")
  331. if (volume.DirtyBitSet = FALSE) then
  332. call WriteLog(" FAILED - dirty bit not set")
  333. else
  334. call WriteLog(" success - dirty bit set")
  335. end if
  336. else
  337. call WriteLog(" REMOTE - skipping dirty bit set and test")
  338. end if
  339. wscript.echo("")
  340. wscript.echo (" chkdsk")
  341. Result = Volume.Chkdsk(True)
  342. rc = ReportIfErr(Err, " FAILED - volume chkdsk method failed")
  343. if (Result = 0) then
  344. wscript.echo " volume.Chkdsk returned no error"
  345. else
  346. wscript.echo " volume.Chkdsk returned error code = " & Result
  347. end if
  348. strMessage = MapErrorCode("Win32_volume", "Chkdsk", Result)
  349. call WriteLog (" Chkdsk error code message = "& strMessage)
  350. set volume = RefreshObject(volume)
  351. wscript.echo ("")
  352. wscript.echo (" checking if diry bit set (failure) or not (success)")
  353. if (volume.DirtyBitSet = TRUE) then
  354. call WriteLog(" FAILED - dirty bit set")
  355. else
  356. call WriteLog(" success - dirty bit not set")
  357. end if
  358. End Function 'end of DoDiskServices
  359. '**********************************************************
  360. Function ListAnalysisReport (objReport)
  361. wscript.echo "Analysis Report"
  362. wscript.echo ""
  363. wscript.echo " Volume size = " & objReport.VolumeSize
  364. wscript.echo " Cluster size = " & objReport.ClusterSize
  365. wscript.echo " Used space = " & objReport.UsedSpace
  366. wscript.echo " Free space = " & objReport.FreeSpace
  367. wscript.echo " Percent free space = " & objReport.FreeSpacePercent
  368. wscript.echo ""
  369. wscript.echo "Volume fragmentation"
  370. wscript.echo " Total fragmentation = " & objReport.TotalPercentFragmentation
  371. wscript.echo " File fragmentation = " & objReport.FilePercentFragmentation
  372. wscript.echo " Free space fragmentation = " & objReport.FreeSpacePercentFragmentation
  373. wscript.echo ""
  374. wscript.echo "File fragmentation"
  375. wscript.echo " Total files = " & objReport.TotalFiles
  376. wscript.echo " Average file size = " & objReport.AverageFileSize
  377. wscript.echo " Total fragmented files = " & objReport.TotalFragmentedFiles
  378. wscript.echo " Total excess fragments = " & objReport.TotalExcessFragments
  379. wscript.echo " Average fragments per file = " & objReport.AverageFragmentsPerFile
  380. wscript.echo ""
  381. wscript.echo "Pagefile fragmentation"
  382. wscript.echo " Pagefile size = " & objReport.PagefileSize
  383. wscript.echo " Total fragments = " & objReport.TotalPagefileFragments
  384. wscript.echo ""
  385. wscript.echo "Folder fragmentation"
  386. wscript.echo " Total folders = " & objReport.TotalFolders
  387. wscript.echo " Fragmented folders = " & objReport.FragmentedFolders
  388. wscript.echo " Excess folder fragments = " & objReport.ExcessFolderFragments
  389. wscript.echo ""
  390. wscript.echo "Master File Table (MFT) fragmentation"
  391. wscript.echo " Total MFT size = " & objReport.TotalMFTSize
  392. wscript.echo " MFT record count = " & objReport.MFTRecordCount
  393. wscript.echo " Percent MFT in use = " & objReport.MFTPercentInUse
  394. wscript.echo " Total MFT fragments = " & objReport.TotalMFTFragments
  395. wscript.echo ""
  396. end Function
  397. '**********************************************************
  398. Function RWPropertyChanger ()
  399. on error resume next
  400. dim tempDeviceID
  401. dim tempDriveLetter
  402. newDriveLetter = "M:"
  403. newLabel = "myLabel"
  404. wscript.echo("")
  405. wscript.echo("Read/Write Property Changer")
  406. wscript.echo(" current drive letter = "&volume.DriveLetter)
  407. tempDeviceID = volume.DeviceID
  408. tempDriveLetter = volume.DriveLetter
  409. ' assign new drive letter
  410. wscript.echo(" putting drive letter as M:")
  411. volume.DriveLetter = newDriveLetter
  412. volume.Put_
  413. rc = ReportIfErr(Err, " FAILED - volume Put operation failed")
  414. '-------------------------------------------------------------
  415. wscript.echo (" doing a refresh")
  416. set volume = RefreshObject(volume)
  417. if (volume.DriveLetter = newDriveLetter) then
  418. call WriteLog (" success - drive letter change")
  419. wscript.echo (" resetting drive letter to orginal")
  420. volume.DriveLetter = tempDriveLetter
  421. volume.Put_
  422. rc = ReportIfErr(Err, " FAILED - volume Put operation failed")
  423. set volume = RefreshObject(volume)
  424. wscript.echo (" drive letter is now set back to = "&volume.DriveLetter)
  425. else
  426. call WriteLog (" FAILED - drive letter change")
  427. end if
  428. wscript.echo ("")
  429. tempLabel = volume.Label
  430. if (isNull (tempLabel) ) then
  431. wscript.echo (" changing current label (=<null>) to new label (="&newLabel&")")
  432. else
  433. wscript.echo (" changing current label (="&volume.Label&") to new label (="&newLabel&")")
  434. end if
  435. volume.Label = newLabel
  436. volume.Put_
  437. rc = ReportIfErr(Err, " FAILED - volume Put operation failed")
  438. wscript.echo (" doing a refresh")
  439. set volume = RefreshObject(volume)
  440. if strComp(volume.Label, newLabel, 1) = 0 then
  441. call WriteLog (" success - label reset")
  442. wscript.echo (" resetting label to orginal")
  443. if (isNull (tempLabel) ) then
  444. volume.Label = ""
  445. wscript.echo (" setting to null")
  446. else
  447. volume.Label = tempLabel
  448. end if
  449. volume.Put_
  450. rc = ReportIfErr(Err, " FAILED - volume Put operation failed")
  451. wscript.echo (" label is now set")
  452. else
  453. call WriteLog (" FAILED - label reset test")
  454. end if
  455. indexCheck = IsNull(volume.IndexingEnabled)
  456. if indexCheck = False then
  457. wscript.echo ("")
  458. wscript.echo (" toggling indexing enabled property")
  459. tempIndexing = volume.IndexingEnabled
  460. wscript.echo (" volume.IndexingEnabled = "&volume.IndexingEnabled)
  461. wscript.echo (" toggling it")
  462. success = false
  463. if (tempIndexing = true) then
  464. volume.IndexingEnabled = false
  465. volume.Put_
  466. rc = ReportIfErr(Err, " FAILED - volume Put operation failed")
  467. wscript.echo (" doing a refresh")
  468. set volume = RefreshObject(volume)
  469. if (volume.IndexingEnabled = false) then
  470. success = true
  471. end if
  472. else
  473. volume.IndexingEnabled = true
  474. volume.Put_
  475. rc = ReportIfErr(Err, " FAILED - volume Put operation failed")
  476. wscript.echo (" doing a refresh")
  477. set volume = RefreshObject(volume)
  478. if (volume.IndexingEnabled = true) then
  479. success = true
  480. end if
  481. end if
  482. if (success = false) then
  483. call WriteLog (" FAILED - toggling indexingenabled")
  484. else
  485. call WriteLog (" success - toggling indexingenabled")
  486. wscript.echo (" setting it back to = "&tempIndexing)
  487. volume.IndexingEnabled = tempIndexing
  488. volume.Put_
  489. rc = ReportIfErr(Err, " FAILED - volume Put operation failed")
  490. end if
  491. end if
  492. end Function
  493. '**********************************************************
  494. Function ListFragmentation (objReport)
  495. wscript.echo "Analysis Report"
  496. wscript.echo ""
  497. wscript.echo " Volume size = " & objReport.VolumeSize
  498. wscript.echo " Cluster size = " & objReport.ClusterSize
  499. wscript.echo " Used space = " & objReport.UsedSpace
  500. wscript.echo " Free space = " & objReport.FreeSpace
  501. wscript.echo " Percent free space = " & objReport.FreeSpacePercent
  502. wscript.echo ""
  503. wscript.echo "Volume fragmentation"
  504. wscript.echo " Total fragmentation = " & objReport.TotalPercentFragmentation
  505. wscript.echo " File fragmentation = " & objReport.FilePercentFragmentation
  506. wscript.echo " Free space fragmentation = " & objReport.FreeSpacePercentFragmentation
  507. wscript.echo ""
  508. wscript.echo "File fragmentation"
  509. wscript.echo " Total files = " & objReport.TotalFiles
  510. wscript.echo " Average file size = " & objReport.AverageFileSize
  511. wscript.echo " Total fragmented files = " & objReport.TotalFragmentedFiles
  512. wscript.echo " Total excess fragments = " & objReport.TotalExcessFragments
  513. wscript.echo " Average fragments per file = " & objReport.AverageFragmentsPerFile
  514. wscript.echo ""
  515. wscript.echo "Pagefile fragmentation"
  516. wscript.echo " Pagefile size = " & objReport.PagefileSize
  517. wscript.echo " Total fragments = " & objReport.TotalPagefileFragments
  518. wscript.echo ""
  519. wscript.echo "Folder fragmentation"
  520. wscript.echo " Total folders = " & objReport.TotalFolders
  521. wscript.echo " Fragmented folders = " & objReport.FragmentedFolders
  522. wscript.echo " Excess folder fragments = " & objReport.ExcessFolderFragments
  523. wscript.echo ""
  524. wscript.echo "Master File Table (MFT) fragmentation"
  525. wscript.echo " Total MFT size = " & objReport.TotalMFTSize
  526. wscript.echo " MFT record count = " & objReport.MFTRecordCount
  527. wscript.echo " Percent MFT in use = " & objReport.MFTPercentInUse
  528. wscript.echo " Total MFT fragments = " & objReport.TotalMFTFragments
  529. wscript.echo ""
  530. end Function
  531. '**********************************************************
  532. function DisplaySummary()
  533. f.Close
  534. Set f = fso.OpenTextFile(logFileName)
  535. wscript.echo ("")
  536. wscript.echo ("***************************************")
  537. wscript.echo (" Test Summary ")
  538. wscript.echo ("***************************************")
  539. wscript.echo ("")
  540. Do While f.AtEndOfStream <> True
  541. wscript.echo(f.ReadLine)
  542. Loop
  543. wscript.echo ("")
  544. wscript.echo ("***************************************")
  545. wscript.echo (" End of Test Summary ")
  546. wscript.echo ("***************************************")
  547. wscript.echo ("")
  548. f.Close
  549. end function
  550. '**********************************************************
  551. Function MapErrorCode(ByRef strClass, ByRef strMethod, ByRef intCode)
  552. set objClass = GetObject(strNamespace).Get(strClass, &h20000)
  553. set objMethod = objClass.methods_(strMethod)
  554. values = objMethod.qualifiers_("values")
  555. if ubound(values) < intCode then
  556. call WriteLog( " FAILED - no error message found for " & intCode & " : " & strClass & "." & strMethod)
  557. MapErrorCode = ""
  558. else
  559. MapErrorCode = values(intCode)
  560. end if
  561. End Function
  562. '**********************************************************
  563. function ValidateAllProperties()
  564. wscript.echo ("")
  565. wscript.echo (" running ValProp.exe on all volumes ...")
  566. DIM objShell, objExec
  567. DIM output
  568. Set objShell = CreateObject("WScript.Shell")
  569. Set objExec = objShell.Exec(strValpropCmd)
  570. Do While objExec.Status = 0
  571. 'WScript.Echo "Exec.Status: " & objExec.Status
  572. WScript.Sleep 100
  573. If Not objExec.StdOut.AtEndOfStream Then
  574. wscript.Echo objExec.StdOut.ReadAll
  575. End If
  576. Loop
  577. end function
  578. '**********************************************************
  579. Function ReportIfErr(ByRef objErr, ByRef strMessage)
  580. ReportIfErr = objErr.Number
  581. if objErr.Number <> 0 then
  582. strError = strMessage & " : " & Hex(objErr.Number) & " : " & objErr.Description
  583. call WriteLog (strError)
  584. objErr.Clear
  585. end if
  586. End Function
  587. Sub WriteLog(ByRef strMessage)
  588. wscript.echo strMessage
  589. f.writeline strMessage
  590. End Sub
  591. Function RefreshObject(ByRef objIn)
  592. on error resume next
  593. Dim strRelPath, rc
  594. set RefreshObject = GetObject(strNamespace).Get(objIn.Path_)
  595. rc = ReportIfErr(Err, "FAILED - " & objIn.Path_.Class & ".Get operation")
  596. End Function