VBS hard disk Read and write statistics (partition read-write statistics) _vbs

Source: Internet
Author: User
Tags chr readline stdin

Winxp,win7,win8

Copy Code code as follows:

' Original content reprint, the reference code core part please indicate the source
Hard disk read and write statistics. vbs
If (Lcase right (wscript.fullname,11) = "Wscript.exe") Then
CreateObject ("Wscript.Shell"). Run ("%comspec%/C" &CHR & "mode con cols=52 lines=22" & "&title hard Drive read-write statistics. vbs BY:FASTSLZ PCEVA Or Batho Me &&cscript.exe//nologo "&CHR (a) & Wscript.scriptfullname &chr (%) &chr), 3:Set WMI = Noth Ing: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 the 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& "Manufacturer Capacity:" &round (size0/1000000000) & "GB" _
&vbCrLf&vbTab& "Actual Capacity:" &round (size0/1073741824,2) & "GB" _
&vbCrLf&vbTab& "Partition Status:" &right (Dskp0,len (DskP0)-2)
If Disk1 <> "" Then WScript.Echo Left (dskp1,1) & ":" &vbTab& Disk1 &vbtab _
&vbCrLf&vbTab& "Manufacturer Capacity:" &round (size1/1000000000) & "GB" _
&vbCrLf&vbTab& "Actual Capacity:" &round (size1/1073741824,2) & "GB" _
&vbCrLf&vbTab& "Partition Status:" &right (Dskp1,len (DskP1)-2)
If Disk2 <> "" Then WScript.Echo Left (dskp2,1) & ":" &vbTab& Disk2 &vbtab _
&vbCrLf&vbTab& "Manufacturer Capacity:" &round (size2/1000000000) & "GB" _
&vbCrLf&vbTab& "Actual Capacity:" &round (size2/1073741824,2) & "GB" _
&vbCrLf&vbTab& "Partition Status:" &right (Dskp2,len (DskP2)-2)
If Disk3 <> "" Then WScript.Echo Left (dskp3,1) & ":" &vbTab& Disk3 &vbtab _
&vbCrLf&vbTab& "Manufacturer Capacity:" &round (size3/1000000000) & "GB" _
&vbCrLf&vbTab& "Actual Capacity:" &round (size3/1073741824,2) & "GB" _
&vbCrLf&vbTab& "Partition Status:" &right (Dskp3,len (DskP3)-2)
If Disk4 <> "" Then WScript.Echo Left (dskp4,1) & ":" &vbTab& Disk4 &vbtab _
&vbCrLf&vbTab& "Manufacturer Capacity:" &round (size4/1000000000) & "GB" _
&vbCrLf&vbTab& "Actual Capacity:" &round (size4/1073741824,2) & "GB" _
&vbCrLf&vbTab& "Partition Status:" &right (Dskp4,len (DskP4)-2)
If Disk5 <> "" Then WScript.Echo Left (dskp5,1) & ":" &vbTab& Disk5 &vbtab _
&vbCrLf&vbTab& "Manufacturer Capacity:" &round (size5/1000000000) & "GB" _
&vbCrLf&vbTab& "Actual Capacity:" &round (size5/1073741824,2) & "GB" _
&vbCrLf&vbTab& "Partition Status:" &right (Dskp5,len (DskP5)-2)
WScript.Echo "↑ Please enter the hard drive number you want to monitor 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
Todo
Dim A
' WScript.Echo ' Run &Ts\3600& ' Hours ' & (TS MoD 3600) \60& "Minutes" & (TS MoD 3600) MoD 60& "SEC"
Set A = WMI. ExecQuery ("select * from Win32_perfrawdata_perfdisk_physicaldisk Where name= '" &DskPs& "")
For each B in A
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 A
R2 = B.diskreadbytespersec
W2 = B.diskwritebytespersec
Next
Set A = Nothing
WScript.Echo Disks & "" &round (sizes/1073741824) & "GB" &vbcrlf _
& "Live read:" & Checksize ((R2-R1)/input) & "/S" &vbcrlf _
& "Real-time Writer:" & Checksize ((W2-W1)/input) & "/S" &vbcrlf _
& "Cumulative script reads:" & Checksize (RA1-RA0) &vbcrlf _
& "Scripting Cumulative write:" & Checksize (wa1-wa0) &vbcrlf _
& "Cumulative read:" & Checksize (R1) &vbcrlf _
& "Cumulative write:" & Checksize (W1) &vbcrlf&vbcrlf&vbcrlf&vbcrlf&vbcrlf&vbcrlf&vbcrlf &vbcrlf&vbcrlf&vbcrlf&vbcrlf&vbcrlf&vbcrlf&vbcrlf _
& "Run" &Ts\3600& "Hours" & (TS MoD 3600) \60& "Minutes" & (TS MoD 3600) mod 60& "Seconds"
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/1073741824,2)) & "GB"
ElseIf SZ => 1048576 Then
SZ = FormatNumber (Round (sz/1048576,2)) & "MB"
ElseIf SZ => 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. vbs
Copy Code code as follows:

' Original content reprint, the reference code core part please indicate the source
If (Lcase right (wscript.fullname,11) = "Wscript.exe") Then
CreateObject ("Wscript.Shell"). Run ("%comspec%/C" &AMP;CHR & "mode con cols=52 lines=22" & "&title partition read-write statistics. vbs BY:FASTSLZ PCEVA Or Batho Me &&cscript.exe//nologo "&AMP;CHR (a) & Wscript.scriptfullname &chr (%) &chr), 3:Set WMI = Noth Ing: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 the 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& "Please enter any 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
Todo
Dim A
Set A = WMI. ExecQuery ("Select * from win32_perfrawdata_perfdisk_logicaldisk Where Name = '" & Dskps & "")
For each B in A
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 A
R2 = B.diskreadbytespersec
W2 = B.diskwritebytespersec
Next
Set A = Nothing
WScript.Echo "Monitoring partition:" &dskps &vbcrlf _
& "Live read:" & Checksize ((R2-R1)/input) & "/S" &vbcrlf _
& "Real-time Writer:" & Checksize ((W2-W1)/input) & "/S" &vbcrlf _
& "Cumulative script reads:" & Checksize (RA1-RA0) &vbcrlf _
& "Scripting Cumulative write:" & Checksize (wa1-wa0) &vbcrlf _
& "Cumulative read:" & Checksize (R1) &vbcrlf _
& "Cumulative write:" & Checksize (W1) &vbcrlf&vbcrlf&vbcrlf&vbcrlf&vbcrlf&vbcrlf&vbcrlf &vbcrlf&vbcrlf&vbcrlf&vbcrlf&vbcrlf&vbcrlf&vbcrlf _
& "Run" &Ts\3600& "Hours" & (TS MoD 3600) \60& "Minutes" & (TS MoD 3600) mod 60& "Seconds"
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/1073741824,2)) & "GB"
ElseIf SZ => 1048576 Then
SZ = FormatNumber (Round (sz/1048576,2)) & "MB"
ElseIf SZ => 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.