The example above will always try to connect a printer no matter if it exists or not.

There is a UDF that checks to see if a printer exists and you can do your magic on the outcome of the UDF.

A better way (in my book) is to just delete all network printers and connect the ones that the users requires. This way you will always have a clean printer setup for the user. If they change departments or no longer require a specific printer it will be removed and the correct printers will be set at the next logon. Also when you remove a printer from your network and do not replace it with the example below user will stop printing to it because it is no longer installed on the user’s computer after the next logon. This will save you some calls from users that have printed something to a printer that no longer exists.

A small example (requires the ArrayEnumKey() UDF):
 Code:
;======== Delete all network printers ========
;Delete all mapped network printers
$key = "HKEY_CURRENT_USER\Printers\Connections"
$printers = ArrayEnumKey($key)
For Each $printer in $printers
	$rc = DelKey($key + "\" + $printer)
Next


UDF Library » PrinterExist() - Check for existence of a Printer
UDF Library » ARRAYENUMKEY() - Creates an array of names of the subkeys contained in a registry key
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.