|
The WshShell and WshNetwork Objects Continued from The Windows Scripting Host Object Model The only two objects in the Windows Scripting Host object model that you can create directly are WshShell and WshNetwork; the rest are obtained by calling methods of WshShell and WshNetwork. For instance, if you wanted to create a new WshShortcut object, you would use the following VBScript code: Dim WshShortcut Set WshShortcut = WshShell .CreateShortcut ("c:\shortcut.lnk") WshShell performs a number of useful shell-related tasks. It retrieves information about the machine, such as processor type, number of processors, and OS version number. WshShell can also return the path to special folders, such as those for the desktop or Start menu. There are even methods for creating, modifying, and deleting Registry entries. The WshShell.Popup method presents the user with a dialog box that you can use to obtain simple yes/no answers from the user. The scripting language you use will probably have functions to handle more complex interactions with the user. If you need to deal with network drives or network printers, you'll need to use the WshNetwork object, which has functions to handle mapping and disconnection. WshNetwork can also enumerate all the currently mapped network drives and printers. It does this with the methods EnumNetworkDrives and EnumPrinterConnections, both of which return WshCollection objects. WshCollection can be obtained only by calling the two enumeration functions in WshNetwork, and it is exactly what the name would suggest--a collection of items, either network drives or network printers. Published as Operating Systems in the 02/10/98 issue of PC Magazine. |
|
TOP |
Copyright (c) 1998 Ziff-Davis Inc. |