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

Home Forums Scripting General Scripting Setting default printer via WSH causing printing issues in Notes 8!

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    JDMils
    Member
    #143700

    I currently run a logon script on the domain which sets the default printer on each workstation:
    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[/CODE]

    An example of how the code is called is:
    [CODE]Call SetDefaultPrinter( “\CLA-SRVCLA-IT-P02” )[/CODE]

    This is the changes I have noticed in the registry:
    [QUOTE]HKEY_CURRENT_USERSoftwareMicrosoftWindows NTCurrentVersionWindows-
    Device = \cla-srvCLA-IT-P02,HP LaserJet 8150 PCL 6,IP_10.3.0.84[/QUOTE]

    But interestingly, if I manually change the default printer in Windows to “\CLA-SRVCLA-IT-P02”, these are the changes made to the registry:
    [QUOTE]HKEY_CURRENT_USERSoftwareMicrosoftWindows NTCurrentVersionWindows-
    Device = \cla-srvCLA-IT-P02,winspool,Ne07:[/QUOTE]

    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)
    [/CODE]

    This is called thus:
    [CODE]intRC = ConnectWindowsNetworkPrinter ( objLogFileName, “\CLA-SRVCLA-IT-P02”, False )[/CODE]

    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[/CODE]

    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.[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[/CODE]

    An example of how the code is called is:
    Call SetDefaultPrinter( “\CLA-SRVCLA-IT-P02” )[/CODE]

    This is the changes I have noticed in the registry:
    [QUOTE]HKEY_CURRENT_USERSoftwareMicrosoftWindows NTCurrentVersionWindows-
    Device = \cla-srvCLA-IT-P02,HP LaserJet 8150 PCL 6,IP_10.3.0.84[/QUOTE]

    But interestingly, if I manually change the default printer in Windows to “\CLA-SRVCLA-IT-P02”, these are the changes made to the registry:
    [QUOTE]HKEY_CURRENT_USERSoftwareMicrosoftWindows NTCurrentVersionWindows-
    Device = \cla-srvCLA-IT-P02,winspool,Ne07:[/QUOTE]

    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)
    [/CODE]

    This is called thus:
    [CODE]intRC = ConnectWindowsNetworkPrinter ( objLogFileName, “\CLA-SRVCLA-IT-P02”, False )[/CODE]

    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[/CODE]

    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.[CODE]Call SetDefaultPrinter( “\CLA-SRVCLA-IT-P02” )[/CODE]

    This is the changes I have noticed in the registry:

    Quote:
    HKEY_CURRENT_USERSoftwareMicrosoftWindows NTCurrentVersionWindows-
    Device = \cla-srvCLA-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-SRVCLA-IT-P02”, these are the changes made to the registry:

    Quote:
    HKEY_CURRENT_USERSoftwareMicrosoftWindows NTCurrentVersionWindows-
    Device = \cla-srvCLA-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:
    ‘ Connect the printer according to the current AD Printer group…..
    intRC = ConnectWindowsNetworkPrinter (objLogFileName, “\” & Print_ServerName & “” & PrinterName, False)
    [/CODE]

    This is called thus:
    [CODE]intRC = ConnectWindowsNetworkPrinter ( objLogFileName, “\CLA-SRVCLA-IT-P02”, False )[/CODE]

    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[/CODE]

    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.[CODE] ‘ Connect the printer according to the current AD Printer group…..
    intRC = ConnectWindowsNetworkPrinter (objLogFileName, “\” & Print_ServerName & “” & PrinterName, False)
    [/CODE]

    This is called thus:
    intRC = ConnectWindowsNetworkPrinter ( objLogFileName, “\CLA-SRVCLA-IT-P02”, False )[/CODE]

    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[/CODE]

    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.[CODE]intRC = ConnectWindowsNetworkPrinter ( objLogFileName, “\CLA-SRVCLA-IT-P02”, False )[/CODE]

    The underlying code for this function is:
    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[/CODE]

    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.[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[/CODE]

    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.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.