exec 列磁盘信息

Option Explicit
Dim action,oShell,oExec,strOut,MyArray,f1,oExec2
Set oShell=WScript.CreateObject("WScript.shell")
use
action=lcase(trim(Wscript.Arguments(0)))
select case action
case "drivetype"
   list
Case "volumeinfo"
list
Case "ntfsinfo"
list
Case "statistics"
list
case else
   WScript.quit
end select
Function str()
Set oExec = oShell.Exec("fsutil.exe fsinfo drives")
      Do While Not oExec.StdOut.AtEndOfStream
      strOut = strOut & oExec.StdOut.Readall
      strout = Replace(strout,Chr(0)," ")
      strout=Replace(strout,vbCrLf,"")
      strout=Replace(strout,Chr(10),"")
      strout=Replace(strout,Chr(13),"")
      strout=Replace(strout,"驱动器:","")
      strOut=Trim(strout)
      Loop
      str=strout
End function     
  
Function list()
   MyArray = Split(str, " ", -1, 1)
   For Each f1 in MyArray
   
    Set oExec2 = oShell.Exec("fsutil.exe fsinfo "& Wscript.Arguments(0) &" "& f1)
    WScript.Echo f1&vbcrlf&oExec2.StdOut.ReadAll

   Next
End function
Function use()
If WScript.Arguments.Count <>1   Then
WScript.Echo WScript.FullName &"drivetype | ntfsinfo | statistics"
WScript.Quit
End if
End function

你可能感兴趣的:(职场,exec,休闲,列磁盘)