Announcement

Collapse
No announcement yet.

Setting default printer via WSH causing printing issues in Notes 8!

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting default printer via WSH causing printing issues in Notes 8!

    I currently run a logon script on the domain which sets the default printer on each workstation:
    Code:
    Private Function SetDefaultPrinter( PrinterName)
    	Dim WSHNetwork
    	
    	Set WSHNetwork = CreateObject("WScript.Network")
    	On Error Resume Next
    	
    	intRC = WriteToFile (objLogFileName,  "+-- SetDefaultPrinter [Started] --+")
    
    	intRC = WriteToFile (objLogFileName,  "| Setting Default printer.")
    	WSHNetwork.SetDefaultPrinter PrinterName
    	' Error -2147352567		=>		Printer does not exist
    	If Err.Number = 0 Then 
    		intRC = WriteToFile (objLogFileName,  "| Default Printer has been set.")
    		SetDefaultPrinter = True
    	Else
    		intRC = WriteToFile (objLogFileName,  "| Default Printer has NOT been set.")	
    		intRC = WriteToFile (objLogFileName,  "| Error Number: " & Err.Number)
    		intRC = WriteToFile (objLogFileName,  "| Error Description: " & Err.Description )
    	End If
    	On Error GoTo 0
    	
    	intRC = WriteToFile (objLogFileName,  "+-- SetDefaultPrinter [End] --+")
    
    End Function
    An example of how the code is called is:
    Code:
    Call SetDefaultPrinter( "\\CLA-SRV\CLA-IT-P02" )
    This is the changes I have noticed in the registry:
    HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows-
    Device = \\cla-srv\CLA-IT-P02,HP LaserJet 8150 PCL 6,IP_10.3.0.84
    But interestingly, if I manually change the default printer in Windows to "\\CLA-SRV\CLA-IT-P02", these are the changes made to the registry:
    HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows-
    Device = \\cla-srv\CLA-IT-P02,winspool,Ne07:
    Why the differences? And going out on a limb here, why does Notes 8 not print to the default printer when the default printer is set via the script but it DOES print to the default printer when the same printer is set manually??!!

    Any help would be appreciated. Thanks.

    PS. FYI. The logon script connects printers to the user's workstation depending on which AD security group the user is a member of. Here's the line of code from the logon script which connects the printers to the workstation:
    Code:
                   	' Connect the printer according to the current AD Printer group.....
    				intRC = ConnectWindowsNetworkPrinter (objLogFileName, "\\" & Print_ServerName & "\" & PrinterName, False)
    This is called thus:
    Code:
    intRC = ConnectWindowsNetworkPrinter ( objLogFileName, "\\CLA-SRV\CLA-IT-P02", False )
    The underlying code for this function is:
    Code:
    Private Function ConnectWindowsNetworkPrinter (objLogFileName, strShareName, boolDefault)
    
            On Error Resume Next
    
            intRC = WriteToFile (objLogFileName, "|  |")
            intRC = WriteToFile (objLogFileName, "|  +- Connecting to Windows Printer '" & Ucase (strShareName) & "'")
    
            objNetwork.AddWindowsPrinterConnection strShareName
            ' Error -2147023095		=>		Printer not found.
            If Err.Number Then
               ConnectWindowsNetworkPrinter = ErrorHandler (objLogFileName, _
                                                            "ConnectWindowsNetworkPrinter", _
                                                            Err, bErrorPopup)
               Exit Function
            End If
    
    '         If boolDefault Then
    '            intRC = WriteToFile (objLogFileName, "|  +- Make '" & UCase (strShareName) & _
    '                                             "' as default Printer.")
    '		objNetwork.SetDefaultPrinter strShareName
    		If Err.Number Then
    			ConnectWindowsNetworkPrinter = ErrorHandler (objLogFileName, "ConnectWindowsNetworkPrinter", Err, bErrorPopup)
    			Exit Function
    		Else
    		        intRC = WriteToFile (objLogFileName, "|  +- Connected to Windows Printer '" & Ucase (strShareName) & "'")
    		End If
    
    '         End If
    
    End Function
    Note also that the logon script code works OK with some workstations and Notes 8.

    Workstations are WinXP SP2 & 3, Server is Windows 2003 R2 server running in a domain.
    Last edited by JDMils; 11th August 2009, 01:32.
    |
    +-- JDMils
    |
    +-- Regional Systems Engineer, DotNet programmer & Jack of all trades
    |
Working...
X