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.
 
 
 
 
 
 

86 lines
3.7 KiB

'//on error resume next
set objArgs = wscript.Arguments
if objArgs.count < 1 then
wscript.echo "Usage defragAnalysis volume"
wscript.quit(1)
end if
strVolume = Replace(objArgs(0), "\", "\\")
'// Get the volume
strQuery = "select * from Win32_Volume where Name = '" & strVolume & "'"
set VolumeSet = GetObject("winmgmts:").ExecQuery(strQuery)
for each obj in VolumeSet
set Volume = obj
exit for
next
wscript.echo "Volume: " & Volume.Name
Result = Volume.DefragAnalysis(fRecommended, objReport)
wscript.echo "result " & result
strMessage = MapErrorCode("Win32_Volume", "DefragAnalysis", Result)
wscript.echo "Volume.DefragAnalysis returned: " & Result & " : " & strMessage
if Result = 0 then
wscript.echo "Analysis Report"
wscript.echo ""
wscript.echo " Volume size = " & objReport.VolumeSize
wscript.echo " Cluster size = " & objReport.ClusterSize
wscript.echo " Used space = " & objReport.UsedSpace
wscript.echo " Free space = " & objReport.FreeSpace
wscript.echo " Percent free space = " & objReport.FreeSpacePercent
wscript.echo ""
wscript.echo "Volume fragmentation"
wscript.echo " Total fragmentation = " & objReport.TotalPercentFragmentation
wscript.echo " File fragmentation = " & objReport.FilePercentFragmentation
wscript.echo " Free space fragmentation = " & objReport.FreeSpacePercentFragmentation
wscript.echo ""
wscript.echo "File fragmentation"
wscript.echo " Total files = " & objReport.TotalFiles
wscript.echo " Average file size = " & objReport.AverageFileSize
wscript.echo " Total fragmented files = " & objReport.TotalFragmentedFiles
wscript.echo " Total excess fragments = " & objReport.TotalExcessFragments
wscript.echo " Average fragments per file = " & objReport.AverageFragmentsPerFile
wscript.echo ""
wscript.echo "Pagefile fragmentation"
wscript.echo " Pagefile size = " & objReport.PagefileSize
wscript.echo " Total fragments = " & objReport.TotalPagefileFragments
wscript.echo ""
wscript.echo "Folder fragmentation"
wscript.echo " Total folders = " & objReport.TotalFolders
wscript.echo " Fragmented folders = " & objReport.FragmentedFolders
wscript.echo " Excess folder fragments = " & objReport.ExcessFolderFragments
wscript.echo ""
wscript.echo "Master File Table (MFT) fragmentation"
wscript.echo " Total MFT size = " & objReport.TotalMFTSize
wscript.echo " MFT record count = " & objReport.MFTRecordCount
wscript.echo " Percent MFT in use = " & objReport.MFTPercentInUse
wscript.echo " Total MFT fragments = " & objReport.TotalMFTFragments
wscript.echo ""
if fRecommended = True then
wscript.echo "this volume should be defragged"
else
wscript.echo "this volume does not need to be defragged"
end if
end if
Function MapErrorCode(ByRef strClass, ByRef strMethod, ByRef intCode)
set objClass = GetObject("winmgmts:").Get(strClass, &h20000)
set objMethod = objClass.methods_(strMethod)
values = objMethod.qualifiers_("values")
if ubound(values) < intCode then
wscript.echo " FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod
f.writeline ("FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod)
MapErrorCode = ""
else
MapErrorCode = values(intCode)
end if
End Function