I am trying to write a small application in VB (just started learning VB today) to add network printers. I found some code on the internet
Dim printername As String = CStr(ListBox1.SelectedItem)
Dim Server As String = "\\server"
Dim networkpath As String = Server & " \ " & printername
Dim useExistingDriver As Boolean = 0
Dim setdefaultprinter As Boolean = 0
Dim cmdToSend As String = "rundll32 printui.dll,PrintUIEntry /in /q /n " & networkpath
If useExistingDriver Then cmdToSend += " /u"
If setDefaultPrinter Then cmdToSend += " /y" '
Shell(cmdToSend, AppWinStyle.Hide) ' execute the command
This is working, but if I have "Spaces" in the printer name, it gives error. Please help.
FYI, I am not using VBscript because I need GUI(comboboxes etc)