"Fossies" - the Fresh Open Source Software Archive

Member "unix/NT4/df.vbs" (15 Sep 2021, 1101 Bytes) of package /linux/misc/pandorafms_agent_unix-7.0NG.757.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Visual Basic source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 ' df.vbs
    2 ' Returns free space for avaible drives.
    3 ' --------------------------------------
    4 
    5 Option Explicit
    6 On Error Resume Next
    7 
    8 ' Variables
    9 Dim objWMIService, objItem, colItems, argc, argv, i
   10 
   11 ' Parse command line parameters
   12 argc = Wscript.Arguments.Count
   13 Set argv = CreateObject("Scripting.Dictionary")
   14 For i = 0 To argc - 1
   15     argv.Add Wscript.Arguments(i), i
   16 Next
   17 
   18 ' Get drive information
   19 Set objWMIService = GetObject ("winmgmts:\\.\root\cimv2")
   20 Set colItems = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")
   21 
   22 For Each objItem in colItems
   23     If argc = 0 Or argv.Exists(objItem.Name) Then
   24         If objItem.FreeSpace <> "" Then
   25             Wscript.StdOut.WriteLine "<module>"
   26             Wscript.StdOut.WriteLine "    <name><![CDATA[" & objItem.Name & "]]></name>"
   27             Wscript.StdOut.WriteLine "    <description><![CDATA[Drive " & objItem.Name & " free space in MB]]></description>"
   28             Wscript.StdOut.WriteLine "    <data><![CDATA[" & Int(objItem.FreeSpace /1048576) & "]]></data>"
   29             Wscript.StdOut.WriteLine "</module>"
   30             Wscript.StdOut.flush
   31         End If
   32     End If
   33 Next