VB Script problems when replacing a logon script
Posted on 2004-10-28
I am using a VB script to map a network drive and to also add network printers to every computer on the network. I had been using a logon script (batch file) to map the drive, but chose to use the vb script when I added the printers. The problem that I am having is that the vb script fails if there is a previous mapped drive with the same drive letter, or if there is already a printer with the same name. I want to know if there is something that I can add to the script that will tell it to overwrite the mapped drives and printers that have the same drive letters or names. Here is an example of the script that I am using.
Set objWSHNetwork = CreateObject("WScript.Network") 'create network object
strConnectString = "\\Dellserver\8400DX"
strResult = objWSHNetwork.AddWindowsPrinterConnection(strConnectString)
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "P:", "\\192.168.0.10\Public"
WshNetwork.MapNetworkDrive "Q:", "\\192.168.0.10\DCC"
WshNetwork.MapNetworkDrive "o:", "\\192.168.0.53\FTP"