Solved

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

Posted on 2001-08-29
14
375 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
Comment Utility
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
Comment Utility
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
Comment Utility
That would mean I have to map all drives of each server to the webserver?
0
 
LVL 9

Expert Comment

by:AlfaNoMore
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Pass then. If there is, I don't know what it is. Maybe it's VB. Have you checked out MSDN Library?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 11

Expert Comment

by:thunderchicken
Comment Utility
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
Comment Utility
You can get all the partition information using WMI Scripting
0
 

Author Comment

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

Expert Comment

by:raizon
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for the points and the grade.  Did this do what you need?
0
 

Author Comment

by:ironeye
Comment Utility
Yep! Great.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
iis reverse proxy virtual directory 8 101
Classic ASP migration directions 7 57
Visual Project Bridge error 5 56
Error viewing ASP page 12 76
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…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

13 Experts available now in Live!

Get 1:1 Help Now