SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 728 | Next

David A. Karp

"Windows Vista Annoyances: Tips, Secrets, and Hacks"


How to Use the Network
WSH has a few limited networking functions built in that can be used for
mapping network drives and connecting to network printers. For advanced
network functionality (such as communication and network traffic
monitoring), check out PowerShell, discussed later in this chapter. For more
information on networking, see Chapter 7.
The following routines provide access to some of the more useful networkrelated
functions in VBScript.
532 | Chapter 9: Scripting and Automation
The following function checks a given drive letter to see whether it has
already been mapped. It returns True (-1) if the drive letter has been
mapped, False (0) if it hasn??™t:
Function AlreadyMapped(DriveLetter)
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set AllDrives = WshNetwork.EnumNetworkDrives( )
If Left(DriveLetter,1) <> ":" then DriveLetter = DriveLetter & ":"
ConnectedFlag = False
For i = 0 To AllDrives.Count - 1 Step 2
If AllDrives.Item(i) = UCase(DriveLetter) Then ConnectedFlag = True
Next
AlreadyMapped = ConnectedFlag
End Function
This subroutine maps a drive letter to any valid remote path:
Sub MapNetDrive(DriveLetter, RemotePath)
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
WShNetwork.MapNetworkDrive DriveLetter, RemotePath
End Sub
This subroutine maps an unused printer port (e.g., LPT3) to any valid
remote network printer:
Sub MapNetPrinter(Port, RemotePath)
Set WshShell = WScript.


Pages:
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6