I have some code that successfully adds a selected printer but when i use the switches for printui.dll to set the printer as default, it doesn't work. The code still adds the printer, just doesn't set it as the default one.
I found the switches from here...
Command Line Printer Control
My code is...
I found the switches from here...
Command Line Printer Control
My code is...
VB.NET:
Try
Dim printername As String = CStr(Form1.ListBox_PrinterResults.SelectedItem)
Dim Server As String = "\\printserver"
Dim networkpath As String = """" & Server & "\" & printername & """"
Dim useExistingDriver As Boolean = 0
Dim setdefaultprinter As Boolean = 0
Dim cmdToSend As String = "rundll32 printui.dll,PrintUIEntry /y /in /q /n" & networkpath
If useExistingDriver Then cmdToSend += " /u"
If setdefaultprinter Then cmdToSend += " /y" '
Shell(cmdToSend, AppWinStyle.Hide) ' execute the command
MsgBox(cmdToSend)
Catch ex As Exception
MsgBox(ex.ToString)
End Try