Asked by:
Displaying remote Disk Drive Free Space
Question
-
User-1131887445 posted
I want to be able to access information from Hard drives across our network such as Memory free, Free Disk Space, etc... Does anyone know of a way to do this from a web form stand point and not a windows form? Thanks.Thursday, December 14, 2006 11:51 AM
All replies
-
User-820230059 posted
You're going to have a lot of trouble getting this done on a web form - without thoes computers "reporting" to the webserver or a database somehow.
Code that runs on the server, lives on the server. So you'd be able to get the free space of the server the webform is running on pretty easily, but the others are going to be outside the scope of your application I think.
What you could do - is write a web service that accepted an input of hard drive space - and write a small application that you installed on each server that sent the free space of the hard drive - back to the web service - for storage - so that you'd have it when the Page was loaded.
Thursday, December 14, 2006 12:22 PM -
User-186692512 posted
Hello.
Under usual security settings, no browser is allowed to access this kind of information.
Thursday, December 14, 2006 12:24 PM -
User1880055189 posted
Although most of the above is true you could potentially use the System.Management interface to query WMI data. However the ASPNET account will require elevated privileges on the machines you wish to query... which is a potential security risk. Also the WMI can be very complex and difficult to grasp which may be more time consuming than you expect. I would not use this method on an internet site, however you could as an intranet app. Also it should be on a Windows domain. Check with your administrator if they would allow the ASPNET account to query WMI Data.
Anyways to get you started here's a few links:
System.Management namespace: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemmanagement.asp
good examples / quick guide: http://aspalliance.com/629#Page2
That last one is pretty good because it goes over how to get, for example, computer hardware > how much free memory does a computer have...
strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") Set colSettings = objWMIService.ExecQuery _ ("Select * from Win32_OperatingSystem") For Each objOperatingSystem in colSettings Wscript.Echo "Available Physical Memory: " & _ objOperatingSystem.FreePhysicalMemory NextHowever note that this is Windows Scripting so it will slightly differ when doing the same thing with .NET
Thursday, December 14, 2006 12:56 PM -
User-1131887445 posted
Hmmm,.... Thanks for the info. I wanted to put that info in a datalist (All servers on network) in the AJAX Update panel with a timer to check the diskspace ever "X" amount of time. looks like there is no way to do that.Thursday, December 14, 2006 1:03 PM -
User-1131887445 posted
Thanks for the help. I was able to accomplish what I am needing to do. I used the function Where "Textbox1.text" is a name of a server. This function only returns the space and free space of a remote server Hard Drive (C:), but I can then do some calculations to get the percentage free and then use that in my monitor. Thanks fo rthe help guys!!!
Dim OperatingSystemInfo As String
Dim managementClass As ManagementClass = New ManagementClass("\\" & TextBox1.Text & "\ROOT\CIMV2:Win32_LogicalDisk")
Dim managementObjectCollection As ManagementObjectCollection = managementClass.GetInstances
Dim sbOperatingSystem As StringBuilder = New StringBuilder
Dim i As Integer = 0
For Each managementObject As ManagementObject In managementObjectCollection
'If OperatingSystemInfo Is Nothing Then
' If i = 0 Then
' label5.Text = "SystemName: " & managementObject("SystemName").ToString
' i += 1
' End If
sbOperatingSystem.Append("Device ID: " & managementObject("DeviceID").ToString & "<br />")
If managementObject("DeviceID").ToString = "C:" Then
sbOperatingSystem.Append("Size: " + managementObject("Size").ToString & "<br />Free Space: " + managementObject("FreeSpace").ToString & "<br />")
End If
'End If
managementObject.Dispose()
Next
label4.Text = sbOperatingSystem.ToString
Return OperatingSystemInfo = sbOperatingSystem.ToString
End FunctionThursday, December 21, 2006 8:55 AM