Chapter 10. Managing Drives and Printers with VBScript and JScript
This chapter completes our look at managing the file system and then moves on to examine managing network resources. You learn how to work with drives and how to examine drive properties. You also learn how to map network drives and configure network printer connections.
Managing Drives
Two different ways of working with drives are available. You can work with a specific drive, such as the C: drive, or you can work with drive collections. Drive collections are containers for all of the local and network drives on a particular system.
Obtaining Drive Information
Most functions that work with drives allow you to reference drive paths in any of these ways:
By drive letter, such as C or D
By drive path, such as C:\ or D:\
By network share path, such as \\PLUTO\MYSHARE or \\SATURN\DATA
Most network drives have a drive designator associated with them as well as a path. For example, the network drive \\PLUTO\MYSHARE may be mapped on the system as the H: drive. You can obtain a drive designator for a network drive using the GetDriveName
method of FileSystemObject
. This method requires a drive path. The following are a few examples of how it is used:
VBScript Set fs = CreateObject("Scripting.FileSystemObject") drv = fs.GetDriveName ("\\PLUTO\DATA") WScript.Echo drv JScript fs = new ActiveXObject("Scripting.FileSystemObject"); ...
Get Microsoft® PowerShell, VBScript and JScript® Bible now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.