WinXP, Win7, Win8
Copy codeThe Code is as follows: 'indicate the source for reprinting original content and referencing the core part of the code.
Hard disk read/write statistics. vbs
If (Lcase (Right (Wscript. FullName, 11) = "wscript.exe") Then
CreateObject ("WScript. shell "). run ("% Comspec %/C" & Chr (34) & "mode con cols = 52 lines = 22" & "& Title hard disk read/write statistics. vbs By: FastSLZ PCEVA Or BatHome &cscript.exe // NoLogo "& Chr (34) & Wscript. scriptFullName & Chr (34) & Chr (34), 3: Set WMI = Nothing: Wscript. quit
End If
Dim WMI, vName, IDE, cPPP, sNow
Input = 1: InputS = Input * 980
On Error Resume Next
Set WMI = GetObject ("winmgmts: {impersonationLevel = impersonate }! \. \ Root \ cimv2 ")
Set IDE = WMI. ExecQuery ("Select * from Win32_DiskDrive WHERE InterfaceType = 'ide '")
Set cPPP = WMI. ExecQuery ("SELECT * FROM Win32_PerfRawData_PerfDisk_PhysicalDisk WHERE Name <> '_ total '")
For Each oIDE In IDE
For I = 0 To IDE. Count
Select Case oIDE. Index
Case I
For Each oPPP In cPPP
If InStr (oPPP. Name, I) Then vName = oPPP. Name
Next
Select Case I
Case 0 Disk0 = oIDE. Caption & "& oIDE. FirmwareRevision: Size0 = oIDE. Size: DskP0 = vName
Case 1 Disk1 = oIDE. Caption & "& oIDE. FirmwareRevision: Size1 = oIDE. Size: DskP1 = vName
Case 2 Disk2 = oIDE. Caption & "& oIDE. FirmwareRevision: Size2 = oIDE. Size: DskP2 = vName
Case 3 Disk3 = oIDE. Caption & "& oIDE. FirmwareRevision: Size3 = oIDE. Size: DskP3 = vName
Case 4 Disk4 = oIDE. Caption & "& oIDE. FirmwareRevision: Size4 = oIDE. Size: DskP4 = vName
Case 5 Disk5 = oIDE. Caption & "& oIDE. FirmwareRevision: Size5 = oIDE. Size: DskP5 = vName
End Select
End Select
Next
Next
Set cPPP = Nothing: Set IDE = Nothing
If Disk0 <> "" Then WScript. Echo Left (DskP0, 1) & ":" & vbTab & Disk0 & vbTab _
& VbCrLf & vbTab & "vendor capacity:" & Round (Size0/1000000000) & "GB "_
& VbCrLf & vbTab & "actual capacity:" & Round (Size0/4153741824,2) & "GB "_
& VbCrLf & vbTab & "partition status:" & Right (DskP0, Len (DskP0)-2)
If Disk1 <> "" Then WScript. Echo Left (DskP1, 1) & ":" & vbTab & Disk1 & vbTab _
& VbCrLf & vbTab & "vendor capacity:" & Round (Size1/1000000000) & "GB "_
& VbCrLf & vbTab & "actual capacity:" & Round (Size1/4153741824,2) & "GB "_
& VbCrLf & vbTab & "partition status:" & Right (DskP1, Len (DskP1)-2)
If Disk2 <> "" Then WScript. Echo Left (DskP2, 1) & ":" & vbTab & Disk2 & vbTab _
& VbCrLf & vbTab & "vendor capacity:" & Round (Size2/1000000000) & "GB "_
& VbCrLf & vbTab & "actual capacity:" & Round (Size2/4153741824,2) & "GB "_
& VbCrLf & vbTab & "partition status:" & Right (DskP2, Len (DskP2)-2)
If Disk3 <> "" Then WScript. Echo Left (DskP3, 1) & ":" & vbTab & Disk3 & vbTab _
& VbCrLf & vbTab & "vendor capacity:" & Round (Size3/1000000000) & "GB "_
& VbCrLf & vbTab & "actual capacity:" & Round (Size3/4153741824,2) & "GB "_
& VbCrLf & vbTab & "partition status:" & Right (DskP3, Len (DskP3)-2)
If Disk4 <> "" Then WScript. Echo Left (DskP4, 1) & ":" & vbTab & Disk4 & vbTab _
& VbCrLf & vbTab & "vendor capacity:" & Round (Size4/1000000000) & "GB "_
& VbCrLf & vbTab & "actual capacity:" & Round (Size4/4153741824,2) & "GB "_
& VbCrLf & vbTab & "partition status:" & Right (DskP4, Len (DskP4)-2)
If Disk5 <> "" Then WScript. Echo Left (DskP5, 1) & ":" & vbTab & Disk5 & vbTab _
& VbCrLf & vbTab & "vendor capacity:" & Round (Size5/1000000000) & "GB "_
& VbCrLf & vbTab & "actual capacity:" & Round (Size5/4153741824,2) & "GB "_
& VbCrLf & vbTab & "partition status:" & Right (DskP5, Len (DskP5)-2)
WScript. Echo "Enter the hard disk number to be monitored and press ENTER"
StdInput = WScript. StdIn. Readline
StdInput = Left (UCase (stdInput), 1)
If stdInput> "5" Or stdInput <"0" Then MsgBox "input error": WScript. Quit
If InStr (DskP0, stdInput) Then Call Network (Disk0, Size0, DskP0)
If InStr (DskP1, stdInput) Then Call Network (Disk1, Size1, DskP1)
If InStr (DskP2, stdInput) Then Call Network (Disk2, Size2, DskP2)
If InStr (DskP3, stdInput) Then Call Network (Disk3, Size3, DskP3)
If InStr (DskP4, stdInput) Then Call Network (Disk4, Size4, DskP4)
If InStr (DskP5, stdInput) Then Call Network (Disk5, Size5, DskP5)
Sub Network (Disks, Sizes, DskPs)
SNow = Now
Do
Dim
'Wscript. Echo "running" & Ts \ 3600 & "hours" & (Ts mod 3600) \ 60 & "Minutes" & (Ts mod 3600) mod 60 & "seconds"
Set A = WMI. ExecQuery ("Select * from Win32_PerfRawData_PerfDisk_PhysicalDisk Where Name = '" & DskPs &"'")
For Each B In
R1 = B. DiskReadBytesPersec
W1 = B. DiskWriteBytesPersec
If RA0 = "" Then RA0 = B. DiskReadBytesPersec Else RA1 = R1 End If
If WA0 = "" Then WA0 = B. DiskWriteBytesPersec Else WA1 = W1 End If
Next
Set A = Nothing
WScript. Sleep (InputS)
Set A = WMI. ExecQuery ("Select * from Win32_PerfRawData_PerfDisk_PhysicalDisk Where Name = '" & DskPs &"'")
For Each B In
R2 = B. DiskReadBytesPersec
W2 = B. DiskWriteBytesPersec
Next
Set A = Nothing
WScript. Echo Disks & "" & Round (Sizes/1073741824) & "GB" & vbCrLf _
& "Real-time read:" & CheckSize (R2-R1)/Input) & "/s" & vbCrLf _
& "Real-time writer:" & CheckSize (W2-W1)/Input) & "/s" & vbCrLf _
& "Script accumulative read:" & CheckSize (RA1-RA0) & vbCrLf _
& "Script accumulative write:" & CheckSize (WA1-WA0) & vbCrLf _
& "Accumulative read upon startup:" & CheckSize (R1) & vbCrLf _
& "Accumulative write upon startup:" & CheckSize (W1) & vbCrLf _
& "Running" & Ts \ 3600 & "Hour" & (Ts mod 3600) \ 60 & "Minute" & (Ts mod 3600) mod 60 & "second"
Ts = DateDiff ("s", sNow, Now) 'ts = Ts + 1
Loop
End Sub
Function CheckSize (SZ)
On Error Resume Next
If sz=> 1073741824 Then
SZ = FormatNumber (Round (SZ/ipv3741824,2) & "GB"
ElseIf SZ = & gt; 1048576 Then
SZ = FormatNumber (Round (SZ/1048576, 2) & "MB"
ElseIf SZ = & gt; 1024 Then
SZ = FormatNumber (Round (SZ/1024,2) & "KB"
Else
SZ = "0" & FormatNumber (Round (SZ/1024,2) & "KB"
End If
CheckSize = Right ("& SZ, 10)
End Function
Partition read/write statistics. vbsCopy codeThe Code is as follows: 'indicate the source for reprinting original content and referencing the core part of the code.
If (Lcase (Right (Wscript. FullName, 11) = "wscript.exe") Then
CreateObject ("WScript. shell "). run ("% Comspec %/C" & Chr (34) & "mode con cols = 52 lines = 22" & "& Title partition read/write statistics. vbs By: FastSLZ PCEVA Or BatHome &cscript.exe // NoLogo "& Chr (34) & Wscript. scriptFullName & Chr (34) & Chr (34), 3: Set WMI = Nothing: Wscript. quit
End If
Input = 1: InputS = Input * 1000
Dim WMI, vName, IDE, cPPP, sNow
On Error Resume Next
Set WMI = GetObject ("winmgmts: {impersonationLevel = impersonate }! \. \ Root \ cimv2 ")
Set IDE = WMI. ExecQuery ("Select * from Win32_DiskDrive WHERE InterfaceType = 'ide '")
Set cPPP = WMI. ExecQuery ("SELECT * FROM Win32_PerfRawData_PerfDisk_PhysicalDisk WHERE Name <> '_ total '")
For Each oIDE In IDE
For I = 0 To IDE. Count
Select Case oIDE. Index
Case I
For Each oPPP In cPPP
If InStr (oPPP. Name, I) Then vName = oPPP. Name
Next
Select Case I
Case 0 Disk0 = oIDE. Caption & "& oIDE. FirmwareRevision: Size0 = oIDE. Size: DskP0 = vName
Case 1 Disk1 = oIDE. Caption & "& oIDE. FirmwareRevision: Size1 = oIDE. Size: DskP1 = vName
Case 2 Disk2 = oIDE. Caption & "& oIDE. FirmwareRevision: Size2 = oIDE. Size: DskP2 = vName
Case 3 Disk3 = oIDE. Caption & "& oIDE. FirmwareRevision: Size3 = oIDE. Size: DskP3 = vName
Case 4 Disk4 = oIDE. Caption & "& oIDE. FirmwareRevision: Size4 = oIDE. Size: DskP4 = vName
Case 5 Disk5 = oIDE. Caption & "& oIDE. FirmwareRevision: Size5 = oIDE. Size: DskP5 = vName
End Select
End Select
Next
Next
Set cPPP = Nothing: Set IDE = Nothing
If Disk0 <> "" Then DskP = Right (DskP0, Len (DskP0)-2): WScript. echo Left (DskP0, 1) & ":" & vbTab & Disk0 & vbTab _
& VbCrLf & vbTab & "partition status:" & Right (DskP0, Len (DskP0)-2)
If Disk1 <> "" Then DskP = DskP & "" & Right (DskP1, Len (DskP1)-2): WScript. echo Left (DskP1, 1) & ":" & vbTab & Disk1 & vbTab _
& VbCrLf & vbTab & "partition status:" & Right (DskP1, Len (DskP1)-2)
If Disk2 <> "" Then DskP = DskP & "" & Right (DskP2, Len (DskP2)-2): WScript. echo Left (DskP2, 1) & ":" & vbTab & Disk2 & vbTab _
& VbCrLf & vbTab & "partition status:" & Right (DskP2, Len (DskP2)-2)
If Disk3 <> "" Then DskP = DskP & "" & Right (DskP3, Len (DskP3)-2): WScript. echo Left (DskP3, 1) & ":" & vbTab & Disk3 & vbTab _
& VbCrLf & vbTab & "partition status:" & Right (DskP3, Len (DskP3)-2)
If Disk4 <> "" Then DskP = DskP & "" & Right (DskP4, Len (DskP4)-2): WScript. echo Left (DskP4, 1) & ":" & vbTab & Disk4 & vbTab _
& VbCrLf & vbTab & "partition status:" & Right (DskP4, Len (DskP4)-2)
If Disk5 <> "" Then DskP = DskP & "" & Right (DskP5, Len (DskP5)-2): WScript. echo Left (DskP5, 1) & ":" & vbTab & Disk5 & vbTab _
& VbCrLf & vbTab & "partition status:" & Right (DskP5, Len (DskP5)-2)
WScript. Echo vbCrLf & "enter any drive letter in" & DskP"
StdInput = WScript. StdIn. Readline
StdInput = Left (UCase (stdInput), 1)
If InStr (DskP, stdInput) Then Call Network (stdInput &":")
Sub Network (DskPs)
SNow = Now
Do
Dim
Set A = WMI. ExecQuery ("Select * from Win32_PerfRawData_PerfDisk_LogicalDisk Where Name = '" & DskPs &"'")
For Each B In
R1 = B. DiskReadBytesPersec
W1 = B. DiskWriteBytesPersec
If RA0 = "" Then RA0 = B. DiskReadBytesPersec Else RA1 = R1 End If
If WA0 = "" Then WA0 = B. DiskWriteBytesPersec Else WA1 = W1 End If
Next
Set A = Nothing
WScript. Sleep (InputS)
Set A = WMI. ExecQuery ("Select * from Win32_PerfRawData_PerfDisk_LogicalDisk Where Name = '" & DskPs &"'")
For Each B In
R2 = B. DiskReadBytesPersec
W2 = B. DiskWriteBytesPersec
Next
Set A = Nothing
WScript. Echo "monitoring partition:" & DskPs & vbCrLf _
& "Real-time read:" & CheckSize (R2-R1)/Input) & "/s" & vbCrLf _
& "Real-time writer:" & CheckSize (W2-W1)/Input) & "/s" & vbCrLf _
& "Script accumulative read:" & CheckSize (RA1-RA0) & vbCrLf _
& "Script accumulative write:" & CheckSize (WA1-WA0) & vbCrLf _
& "Accumulative read upon startup:" & CheckSize (R1) & vbCrLf _
& "Accumulative write upon startup:" & CheckSize (W1) & vbCrLf _
& "Running" & Ts \ 3600 & "Hour" & (Ts mod 3600) \ 60 & "Minute" & (Ts mod 3600) mod 60 & "second"
Ts = DateDiff ("s", sNow, Now) 'ts = Ts + 1
Loop
End Sub
Function CheckSize (SZ)
On Error Resume Next
If sz=> 1073741824 Then
SZ = FormatNumber (Round (SZ/ipv3741824,2) & "GB"
ElseIf SZ = & gt; 1048576 Then
SZ = FormatNumber (Round (SZ/1048576, 2) & "MB"
ElseIf SZ = & gt; 1024 Then
SZ = FormatNumber (Round (SZ/1024,2) & "KB"
Else
SZ = "0" & FormatNumber (Round (SZ/1024,2) & "KB"
End If
CheckSize = Right ("& SZ, 10)
End Function