Solved

Get disksize and free space of hd's from remote server

Posted on 2001-08-29
14
376 Views
Last Modified: 2008-02-01
How can I do this in my web-application? I have the servernames or IP-adresses.

Thnx.
0
Comment
Question by:ironeye
  • 5
  • 4
  • 4
  • +1
14 Comments
 
LVL 9

Expert Comment

by:AlfaNoMore
ID: 6436057
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set Drives = objFSO.Drives
For Each Drive in Drives
   Drive.AvailableSpace 'size of HD
   Drive.FreeSpace 'you guessed it :-)
Next

You can connect to any drive that is networked to your server. Map a network connection to the external machine if needed.

Seems you can't go direct to the drive using objFSO.GetDrive("D:\"), which would have been good, instead you'll have to loop through all available until you find the right one!
0
 
LVL 9

Expert Comment

by:AlfaNoMore
ID: 6436060
Here's the full property list for the Drives object:

Drive.AvailableSpace
Drive.DriveLetter
Drive.DriveType
Drive.FileSystem
Drive.FreeSpace
Drive.IsReady
Drive.Path
Drive.SerialNumber
Drive.ShareName
Drive.TotalSize
Drive.VolumeName
0
 

Author Comment

by:ironeye
ID: 6436064
That would mean I have to map all drives of each server to the webserver?
0
 
LVL 9

Expert Comment

by:AlfaNoMore
ID: 6436102
That would be the whole point of Network security! You can't just access any drive remotely without permission -- unless you create your own hacking software? You probably could execute a registry key for each drive (which maps it), and then clean it up afterwards, but that's not any easier than mapping it yourself!
0
 
LVL 9

Expert Comment

by:AlfaNoMore
ID: 6436108
And you might not want to perform this check everytime anyway. You might think about performing the check once a day or something to free up resources. Save the results to a text file, and each use can read from that?
0
 

Author Comment

by:ironeye
ID: 6436117
It's for a server inventory tool so that the IT department can look if a harddisk is running full without having to use the SMS-service. I've seen it done in perl so I wondered if it could be done with ASP/VBs.
0
 
LVL 9

Expert Comment

by:AlfaNoMore
ID: 6436157
Pass then. If there is, I don't know what it is. Maybe it's VB. Have you checked out MSDN Library?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Expert Comment

by:thunderchicken
ID: 6437704
You can not use FSO on mapped drives because they are a service.

Have you tried using the UNC path, ie \\Computername
0
 
LVL 5

Expert Comment

by:raizon
ID: 6438245
You can get all the partition information using WMI Scripting
0
 

Author Comment

by:ironeye
ID: 6439253
raizon, that's new to me. Do u have a example for me?
0
 
LVL 5

Expert Comment

by:raizon
ID: 6442984
yes I do but I won't be able to get it for you until tomorrow at work.  I'll post it here.
0
 
LVL 5

Accepted Solution

by:
raizon earned 100 total points
ID: 6446308
Give this a shot.  YOu do need to have administrative access so make sure to set basic authentication in IIS for this.  Set vComputerName to the name of the server you want to check.

<%
Function ShowDiskPartition(vComputerName)
     Dim objLocator, objService, objWEBMCol, objWEBM
     Set objLocator = CreateObject("WbemScripting.SWbemLocator")
     
     'Establish a connection to WMI
     If isEmpty(vComputerName) = True then
          Set objService = objLocator.ConnectServer
     Else
          Set objService = objLocator.ConnectServer(vComputerName)
     End If
     
     'Get the Webm Service object
     Set objWEBMCol = objService.InstancesOf("Win32_DiskPartition")
     Response.write "<H2> Disk Partition:</H2><HR><UL>"
     
     'Enumerate
     For Each objWEBM in objWEBMCol
          Response.write "<LI>Availability: " & objWEBM.Availability
          & _ ", <BR>Caption: " & objWEBM.Caption
          & _ ", <BR>Block Size: " & objWEBM.BlockSize
          & _ ", <BR>Bootable: " & objWEBM.Bootable
          & _ ", <BR>Boot Partition: " & objWEBM.BootPartition
          & _ ", <BR>Description: " & objWEBM.Description
          & _ ", <BR>Device ID: " & objWEBM.DeviceID
          & _ ", <BR>Disk Index: " & objWEBM.DiskIndex
          & _ ", <BR>Hidden Sectors: " & objWEBM.HiddenSectors
          & _ ", <BR>Number Of Blocks: " & objWEBM.NumberOfBlocks
          & _ ", <BR>Plug and Play device identifier: " & objWEBM.PNPDeviceID
          & _ ", <BR>Power Management Supported: " & objWEBM.PowerManagementSupported
          & _ ", <BR>Primary Partition: " & objWEBM.PrimaryPartition
          & _ ", <BR>Size: " & objWEBM.Size
          & _ ", <BR>Starting Offset: " & objWEBM.StartingOffset
          & _ ", <BR>Status: " & objWEBM.Status
          & _ ", <BR>System Name: " & objWEBM.SystemName
          & _ ", <BR>Type: " & objWEBM.Type & "<BR></LI>"
     Next
     Response.write "</UL>"
     'Clean up
     Set objLocator = Nothing
     Set objService = Nothing
     Set objWEBMCol = Nothing
     Set objWEBM = Nothing
End Function

Call ShowDiskPartition(vComputerName)
%>
0
 
LVL 5

Expert Comment

by:raizon
ID: 6453060
Thanks for the points and the grade.  Did this do what you need?
0
 

Author Comment

by:ironeye
ID: 6453063
Yep! Great.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now