Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remote NT Server Disk Space

Status
Not open for further replies.

arouhi

Programmer
Jul 7, 2001
29
0
0
US
Is there any way that I can get the amount of Disk Space on a Remote NT server with-out using 2000/XP WMI or Network Mapped Drives?

-Thank You!
 
Code:
'In general section
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, lpFreeBytesAvailableToCaller As Currency, lpTotalNumberOfBytes As Currency, lpTotalNumberOfFreeBytes As Currency) As Long
Private Sub Form_Load()
    Dim r As Long, BytesFreeToCalller As Currency, TotalBytes As Currency
    Dim TotalFreeBytes As Currency, TotalBytesUsed As Currency
    'the drive to find
    Const RootPathName = "\\server\c$"
    'get the drive's disk parameters
    Call GetDiskFreeSpaceEx(RootPathName, BytesFreeToCalller, TotalBytes, TotalFreeBytes)
    'show the results, multiplying the returned
    'value by 10000 to adjust for the 4 decimal
    'places that the currency data type returns.
    Me.AutoRedraw = True
    Me.Cls
    Me.Print
    Me.Print " Total Number Of Bytes:", Format$(TotalBytes * 10000, "###,###,###,##0") & " bytes"
    Me.Print " Total Free Bytes:", Format$(TotalFreeBytes * 10000, "###,###,###,##0") & " bytes"
    Me.Print " Free Bytes Available:", Format$(BytesFreeToCalller * 10000, "###,###,###,##0") & " bytes"
    Me.Print " Total Space Used :", Format$((TotalBytes - TotalFreeBytes) * 10000, "###,###,###,##0") & " bytes"
End Sub
 
Well, if we're allowed to use the Admin shares (as above) then the following is somewhat easier:
[tt]
Private Sub Command1_Click()
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
MsgBox fso.GetDrive("\\server\c$").FreeSpace & " bytes free"
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top