Solved

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

Posted on 2001-08-29
14
377 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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
 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
pass url parameter as session 9 52
EOF BOF error classic asp 8 46
ASP Button to clear text 4 52
Select case on click 3 13
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

816 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

10 Experts available now in Live!

Get 1:1 Help Now