error on EnumPrinterConnections

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
erictoirkens
Posts: 2
Joined: Wed Mar 14, 2012 11:37 pm

error on EnumPrinterConnections

Post by erictoirkens » Wed Mar 14, 2012 11:37 pm

Hi,

part of our loginscript is checking for new printers on our printserver. All of a sudden it fails with a 'unknown exception'-error. Below a test-script which lists printerconnections and also fails:

Code: Select all

 Set objNetwork = CreateObject("WScript.Network")
objDrive = objNetwork.EnumPrinterConnections

For intDrive = 0 to objDrive.Count -1 Step 2
intNetLetter = IntNetLetter +1
WScript.Echo "UNC Path " & objDrive.Item(intDrive) & " = " _
& objDrive.Item(intDrive +1) & " Mapped drive No : " & intDrive
Next
It fails at line 2 (objDrive = objNetwork.EnumPrinterConnections). Isn't the EnumPrinterConnections method usable anymore? I hope someone can help me with this.Thanks, Eric

User avatar
erictoirkens
Posts: 2
Joined: Wed Mar 14, 2012 11:37 pm

error on EnumPrinterConnections

Post by erictoirkens » Thu Mar 15, 2012 1:04 am

Thanks for your reply. To test, I removed 'set' in the script and forgot to put it back before I posted it. Code should be

Code: Select all

	
	Set objNetwork = CreateObject("WScript.Network")
Set objDrive = objNetwork.EnumPrinterConnections
'.EnumPrinterConnections

For intDrive = 0 to objDrive.Count -1 Step 2
intNetLetter = IntNetLetter +1
WScript.Echo "UNC Path " & objDrive.Item(intDrive) & " = " _
& objDrive.Item(intDrive +1) & " Mapped drive No : " & intDrive
Next

Locked