Print Page | Close Window

View Hard Drive Properties

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6133
Printed Date: 31 March 2026 at 5:13am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: View Hard Drive Properties
Posted By: KCWebMonkey
Subject: View Hard Drive Properties
Date Posted: 03 October 2003 at 7:01am
Anyone know how to view the properties of a hard drive remotely?



Replies:
Posted By: michael
Date Posted: 03 October 2003 at 7:21am
If you want to know capacity and what's on it you can use FSO but ig you want to see wether it's a Maxtor or Seagate and Cylinders and Heads and stuff I do not think it is possible without a component, unless you use the WMI Provider withing a WSH script or so, that should work. If you were using ASP.Net you could use WSI to get System Properties.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: KCWebMonkey
Date Posted: 03 October 2003 at 7:30am

I have this script, and it gives a Server.CreateObject Failed error for the A: drive. Is that because there's not floppy in the drive?

<%@ LANGUAGE = "VBSCRIPT" %>
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
 <meta http-equiv="Content-Language" content="bg">
 <title>Show all available drives on local computer.</title>
</head>
<body>
<table border="1" cellpadding="0" width="475" cellspacing="0">
<%
 Dim mfObject
 Dim show
 
 ' Check if drive(s) is ready if ready you can list directory on next page
 Sub ch_Drive ( dr_Name )
  If show.IsReady = True Then
   Response.write "<a href='sh_drive.asp?nDrive=" & show.RootFolder & "&Type="& show.DriveType &"'>" & show.DriveLetter & dr_Name & "</a>"
  Else
   Response.write show.DriveLetter & dr_Name
  End If
 End Sub
 
 ' set file Object
 Set mfObject=Server.CreateObject("Scripting.FileSystemObject")
%>
  <tr>
  <td width="51" valign="middle" align="center" height="27" bgcolor="#FF0000"><font face="Verdana" size="2" color="#FFFFFF"><b>Type</b></font></ td>
  <td width="133" valign="middle" align="center" height="27" bgcolor="#FF0000"><font face="Verdana" size="2" color="#FFFFFF"><b>Name</b></font></ td>
    <td width="131" valign="middle" align="center" height="27" bgcolor="#FF0000"><b><font face="Verdana" color="#FFFFFF" size="1">Total size in bytes</font></b></td>
    <td width="142" valign="middle" align="center" height="27" bgcolor="#FF0000"><b><font face="Verdana" color="#FFFFFF" size="1">Free Space in bytes</font></b></td>
   </tr>
<%
 ' Display all available drives in you local computer
 FOR EACH show in mfObject.Drives
%>
  <tr>
    <td valign="middle" align="center" width="51">
<%
 ' What type is your drive ?
 Select Case show.DriveType
  Case 1
   Response.write "<img border='0' src='images/flopys.gif'>"
  Case 2
   Response.write "<img border='0' src='images/disks.gif'>"
  Case 4
   Response.write "<img border='0' src='images/cdroms.gif'>"
 End Select
%>
  </td>
  <td valign="middle" width="133"><font face="Verdana" size="1" color="#000000">
<%
 Select Case show.DriveType
  Case 1
   Call ch_Drive ( ":> Floppy Disk" )
  Case 2
   Call ch_Drive ( ":> Local Disk" )
  Case 4
   Call ch_Drive ( ":> Compact Disk" )
  End Select
%>
  </font></td>
  <td valign="middle" width="131" align="center"><font face="Verdana" size="1" color="#000000">
<%
 ' max size in bytes
  on error resume next
  Response.write show.TotalSize
  Call err_Describe ( 71 )
%>
  </font></td>
  <td valign="middle" width="142" align="center"><font face="Verdana" size="1" color="#000000">
<%
 ' max available size in bytes
 on error resume next
 Response.write show.AvailableSpace
 Call err_Describe ( 71 )
%>
  </font></td>
 </tr>
<% Next %>
</table>
<%
 ' Catch error number
 Sub err_Describe ( er_number )
  If err.number = er_number Then
   Response.write "<b><font face='Verdana' size='1' color='#FF0000'>"
   Response.write err.description
   Response.write "</b></font>"
  End If
 End Sub
%>
</body>
</html>



Posted By: KCWebMonkey
Date Posted: 03 October 2003 at 10:00am

Here's my finished code in case anyone has a use for it:

<%@ LANGUAGE = "VBSCRIPT" %>
<% Option Explicit %>
<%
    Dim fso, connectedDrives, drv
    Dim strInfo, driveName
    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    Set connectedDrives = fso.drives
    On Error Resume Next
%>
<HTML>
<HEAD>
 <TITLE>Drive Information</TITLE>
</HEAD>
<BODY>
<TABLE CELLPADDING="3" CELLSPACING="1" style="border: solid 1px #000000; font-family: Arial; font-size: 10pt;">
 <TR BGCOLOR="F5F5F5" style="font-weight: bold;">
  <TD style="border: solid 1px #000000;">Drive Letter</TD>
  <TD style="border: solid 1px #000000;">Drive Type</TD>
  <TD style="border: solid 1px #000000;">File System</TD>
  <TD style="border: solid 1px #000000;">Serial Number</TD>
  <TD style="border: solid 1px #000000;">Name</TD>
  <TD style="border: solid 1px #000000;">Available Space</TD>
  <TD style="border: solid 1px #000000;">Total Size</TD>
  <TD style="border: solid 1px #000000;">Ready/Not Ready</TD>
 </TR>
<%
 For Each drv In connectedDrives
%>
 <TR>
  <TD style="border: solid 1px #F5F5F5;"><%=drv.DriveLetter%>:&nbsp;</TD> ;
  <TD style="border: solid 1px #F5F5F5;"><%=drv.DriveType%>&nbsp;</TD>
  <TD style="border: solid 1px #F5F5F5;"><%=drv.FileSystem%>&nbsp;</TD>
  <TD style="border: solid 1px #F5F5F5;"><%=drv.SerialNumber%>&nbsp;</TD> ;
<% If drv.DriveType = 3 Then %>
  <TD style="border: solid 1px #F5F5F5;"><%=drv.ShareName%>&nbsp;</TD>
<% Else %>
  <TD style="border: solid 1px #F5F5F5;"><%=drv.VolumeName%>&nbsp;</TD>
<% End If %>
  <TD style="border: solid 1px #F5F5F5;"><%=drv.AvailableSpace%>&nbsp;</TD& gt;
<% If drv.IsReady Then %>
  <TD style="border: solid 1px #F5F5F5;"><%=drv.TotalSize%>&nbsp;</TD>
  <TD style="border: solid 1px #F5F5F5;">Ready</TD>
<% Else %>
  <TD style="border: solid 1px #F5F5F5;">&nbsp;</TD>
  <TD style="border: solid 1px #F5F5F5;">Not Ready</TD>
<% End If %>
 </TR>
<% Next %>
</TABLE>
<BR>
<TABLE CELLPADDING="1" CELLSPACING="1" style="border: solid 1px #000000; font-family: Arial; font-size: 10pt;">
 <TR>
  <TD style="font-weight: bold;">Drive Letter: </TD>
  <TD>Returns the drive letter of the drive.</TD>
 </TR>
 <TR>
  <TD style="font-weight: bold;">Drive Type: </TD>
  <TD>Returns the drive type, a numerical value, which can be 0 - Unknown,1 - Removable, 2 - Fixed, 3 - Network, 4 - CD-ROM, 5 - RAM Disk.</TD>
 </TR>
 <TR>
  <TD style="font-weight: bold;">File System: </TD>
  <TD>Returns the filesystem of the drive, e.g. NTFS,FAT32.</TD>
 </TR>
 <TR>
  <TD style="font-weight: bold;">Serial Number: </TD>
  <TD>Returns the serial number of the drive.</TD>
 </TR>
 <TR>
  <TD style="font-weight: bold;">Name: </TD>
  <TD>If the drive is shared on a network, this returns the shared-name of the drive.</TD>
 </TR>
 <TR>
  <TD></TD>
  <TD>If the drive hasn't been named and is called the default 'Local Disk' then this property returns an empty string.</TD>
 </TR>
 <TR>
  <TD style="font-weight: bold;">Available Space: </TD>
  <TD>Returns available space left on drive.</TD>
 </TR>
 <TR>
  <TD style="font-weight: bold;">Total Size:</TD>
  <TD>Returns the total size of the drive.</TD>
 </TR>
 <TR>
  <TD style="font-weight: bold;">Ready / Not Ready</TD>
  <TD>Returns whether the drive is ready. If the drive is removable such as a floppy drive returns true if there is a disk or media in the drive.</TD>
 </TR>
</TABLE>
</BODY>
</HTML>
<%
 Set connectedDrives = Nothing
 Set fso = Nothing
%>




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net