I have enhaced the code slightly so that it logs every printer found not just the network ones.
Code:
'Loop round all printers, only list ones that start \\
Set WSHPrinters = WSHNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
If Left(WSHPrinters.Item(LOOP_COUNTER +1),2) = "\\" Then
LogMsg("Found Network Printer: "&WSHPrinters.Item(LOOP_COUNTER +1))
Else
LogMsg("Found Local Printer: "&WSHPrinters.Item(LOOP_COUNTER +1))
End If
Next This gives the following at logon: (printer names replaced by ***)
Code:
21/09/2009 15:56:30: Listing all mapped network printers...<br />
21/09/2009 15:56:40: Found Local Printer: ***
21/09/2009 15:56:40: Found Local Printer: ***
21/09/2009 15:56:40: Found Local Printer: ***
21/09/2009 15:56:40: Found Local Printer: ***
21/09/2009 15:56:40: Found Local Printer: ***
21/09/2009 15:56:40: Found Local Printer: ***
21/09/2009 15:56:40: Found Local Printer: ***
21/09/2009 15:56:40: Found Network Printer: \\***\***
21/09/2009 15:56:40: Found Network Printer: \\***\***
If I run the code after logon there is no delay, or indeed if I run the same code again later on in the script there is no delay.
If I put a sleep in the script to say wait 2 mins and then list the printers, this makes no difference the script still sits there for 10 seconds.
It looks like it is actually conncting to the server to verify the printers exist. Could this casue the delay?