1 Replies - 751 Views - Last Post: 15 February 2013 - 04:38 PM Rate Topic: -----

#1 Scynic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-February 13

Installing Remote TCP/IP Printer via VB.NET

Posted 06 February 2013 - 07:13 AM

I'm trying to write an application that allows our administrators to install a printer onto a Win 7 PC remotely.

So far what I have works perfectly to install a printer on my computer. But when I run it from another user's I get incorrect argument errors. I'm not sure if I should be posting this on Microsoft's forums since it uses their printui.dll and PrintUIEntry, but I thought someone might've had some experience working with this.

Also, if you have any recommendations on how to do this in an easier manner, please feel free to interject. I'm all self-taught and I am still learning.

Here's my Code:


Private Sub btnInstall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInstall.Click
        If Me.txtComputerName.Text <> Nothing Or Me.txtIPAddress.Text <> Nothing Or Me.txtPrinterName.Text <> Nothing Then
            Dim objWriter As New System.IO.StreamWriter("\\" & Me.txtComputerName.Text & "\C$\Temp\InstallPrinter.bat")

            objWriter.WriteLine("@echo off")
            objWriter.WriteLine("cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\prnport.vbs -s " & Me.txtComputerName.Text & " -a -r " & Me.txtIPAddress.Text & " -h " & Me.txtIPAddress.Text & " -o raw -n 9100 -me")
            objWriter.WriteLine("pause")
            objWriter.WriteLine("rundll32 printui.dll,PrintUIEntry /ia /c\\" & Me.txtComputerName.Text & " /m " & ControlChars.Quote & PrntDriver & ControlChars.Quote & " /h " & ControlChars.Quote & OSVer & ControlChars.Quote & " /f \\" & Me.txtComputerName.Text & "\C$\windows\inf\ntprint.inf")
            objWriter.WriteLine("echo Driver Installed Successfully...")
            objWriter.WriteLine("pause")
            objWriter.WriteLine("rundll32 printui.dll,PrintUIEntry /if /b " & ControlChars.Quote & Me.txtPrinterName.Text & ControlChars.Quote & " /c\\" & Me.txtComputerName.Text & " /f \\" & Me.txtComputerName.Text & "\C$\windows\inf\ntprint.inf" & "/r " & ControlChars.Quote & Me.txtIPAddress.Text & ControlChars.Quote & " /m " & ControlChars.Quote & PrntDriver & ControlChars.Quote)
            objWriter.WriteLine("echo Printer Installed Successfully...")
            objWriter.WriteLine("pause")
            objWriter.Close()


            Shell("\\" & Me.txtComputerName.Text & "\C$\Temp\InstallPrinter.bat")

            Call Form1.ShowButtons()
            Me.Close()
        Else
            MessageBox.Show("Please fill in all fields.")
        End If

    End Sub



Thanks!
-Scynic

Is This A Good Question/Topic? 0
  • +

Replies To: Installing Remote TCP/IP Printer via VB.NET

#2 tycos  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 53
  • Joined: 12-February 13

Re: Installing Remote TCP/IP Printer via VB.NET

Posted 15 February 2013 - 04:38 PM

I have only ever done this through a simple batch file that prompted for the computer name and run the wizard using:

RUNDLL32 PRINTUI.DLL,PrintUIEntry /il /c\\machine
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1