The first one uses the file system object So you need to set references to the MS Scripting dll. Instead of using Wscript.Echo "Available space: " & objDrive.AvailableSpace in Access use
MsgBox objDrive.AvailableSpace The same goes for the second one.
CODE
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = objFSO.Drives
For Each objDrive in colDrives
Wscript.Echo "Available space: " & objDrive.AvailableSpace
Wscript.Echo "Drive letter: " & objDrive.DriveLetter
Wscript.Echo "Drive type: " & objDrive.DriveType
Wscript.Echo "File system: " & objDrive.FileSystem
Wscript.Echo "Free space: " & objDrive.FreeSpace
Wscript.Echo "Is ready: " & objDrive.IsReady
Wscript.Echo "Path: " & objDrive.Path
Wscript.Echo "Root folder: " & objDrive.RootFolder
Wscript.Echo "Serial number: " & objDrive.SerialNumber
Wscript.Echo "Share name: " & objDrive.ShareName
Wscript.Echo "Total size: " & objDrive.TotalSize
Wscript.Echo "Volume name: " & objDrive.VolumeName
Next
The second use's Windows WMI script which is how windows 2000 and up queries the operating system instead of using API Calls. You need to set a reference to the WMI Scripting dll.
CODE
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Volume")
For Each objItem In colItems
WScript.Echo "Automount: " & objItem.Automount
WScript.Echo "Block Size: " & objItem.BlockSize
WScript.Echo "Capacity: " & objItem.Capacity
WScript.Echo "Caption: " & objItem.Caption
WScript.Echo "Compressed: " & objItem.Compressed
WScript.Echo "Device ID: " & objItem.DeviceID
WScript.Echo "Dirty Bit Set: " & objItem.DirtyBitSet
WScript.Echo "Drive Letter: " & objItem.DriveLetter
WScript.Echo "Drive Type: " & objItem.DriveType
WScript.Echo "File System: " & objItem.FileSystem
WScript.Echo "Free Space: " & objItem.FreeSpace
WScript.Echo "Indexing Enabled: " & objItem.IndexingEnabled
WScript.Echo "Label: " & objItem.Label
WScript.Echo "Maximum File Name Length: " & objItem.MaximumFileNameLength
WScript.Echo "Name: " & objItem.Name
WScript.Echo "Quotas Enabled: " & objItem.QuotasEnabled
WScript.Echo "Quotas Incomplete: " & objItem.QuotasIncomplete
WScript.Echo "Quotas Rebuilding: " & objItem.QuotasRebuilding
WScript.Echo "Serial Number: " & objItem.SerialNumber
WScript.Echo "Supports Disk Quotas: " & objItem.SupportsDiskQuotas
WScript.Echo "Supports File-Based Compression: " & objItem.SupportsFileBasedCompression
WScript.Echo
Next
Both are saved as .vbs files if you want to run them as stand alone scripts.
WMI scripts can be run on any computers running Windows 98 or Windows ME with WMI Scripting installed or on any computer running Windows 2000 and up.
The Scripts are used mainly to help network administrators accomplish unattented tasks but i have found them to be usefull in Access programming as well as VB.
This site will allow you to download a help file list a variatey of scripts. Once you understand how they work you will be writing your own.
http://www.microsoft.com/technet/scriptcenter
Edited by: GlenKruger on Wed Jan 19 17:26:31 EST 2005.
Edited by: GlenKruger on Mon Jan 24 13:27:43 EST 2005.