+ Post New Thread
Results 1 to 2 of 2
Scripts Thread, VBS Printer Scripting install Printer to a local port (network share) in Coding and Web Development; Been tearing my hair out with this. we have several room which need the printers to be changed as the ...
  1. #1

    Join Date
    Sep 2010
    Posts
    640
    Thank Post
    28
    Thanked 76 Times in 71 Posts
    Rep Power
    22

    VBS Printer Scripting install Printer to a local port (network share)

    Been tearing my hair out with this.

    we have several room which need the printers to be changed as the ports are going to be wrong when the servers are changed (ports names wrong)

    the printers are install as a local port printer with the port set to "\\servername\printersharename"
    so when you look at the port properties it says local port and then lists the share.

    i have tried using PRNadmin.dll and VBS but i get an error about the module not found (script is just installing a dummy to make sure the script functions as im not that good at scripting lol)

    dim oMaster
    dim oPrinter
    set oMaster = CreateObject("PrintMaster.PrintMaster.1")
    set oPrinter = CreateObject("Printer.Printer.1")
    oPrinter.PrinterName = "test_Printer"
    oPrinter.DriverName = "Epson T-1000"
    oPrinter.PortName = "lpt1:"

    oMaster.PrinterAdd oPrinter

    if Err <> 0 then
    'An Error Occurred
    end if

    so looked at using prnport.vbs prnmngr.vbs which work but install the printer using direct IP which is not what is required.

    RUNDLL32 PRINTUI.DLL,PrintUIEntry doesnt appear to support local printing ports to shares?

    going round the houses so looking for a point on which is the better route to take.
    thanks
    Last edited by SHimmer45; 3rd May 2012 at 02:00 PM.

  2. #2

    Join Date
    Sep 2010
    Posts
    640
    Thank Post
    28
    Thanked 76 Times in 71 Posts
    Rep Power
    22
    Ok after some head scratching have managed to get PrintUI to play with local port printing.
    well its not actually installing the port itself but providing the port is already on the machine it can install a printer to it.

    so with a little addition to the registry with the new port names in my limited testing it appears to behave.

    sample code Adding a port:

    sc \\"PC_NAME" stop spooler
    REG ADD "\\PC_NAME\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports" /v \\SERVER_NAME\PRINTER /t REG_SZ
    sc \\"PC_NAME" start spooler

    then another bat file with

    rundll32 printui.dll PrintUIEntry /if /F "DRIVER_INFPATH" /b "Label of printer" /r "Printer Port Name" /m "Printer Name In Driver" /c\\PC_NAME

    gives 2 batches which are quite large (also added in options for removal of old printers and drivers) but seem to do the trick.

    id like to have been able to not have to keep creating the PC_Name each time and the script do that itself based on just being given a location and then going from 1-32 for each pc (so art-pc-1 - art-pc-31)

    anyway someone might find this useful if they are deploying local port printing.

  3. Thanks to SHimmer45 from:

    jonnykewell1 (3rd October 2014)



SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 4
    Last Post: 23rd May 2012, 12:43 AM
  2. Install Printers via Script
    By SimpleSi in forum Windows 7
    Replies: 19
    Last Post: 5th October 2011, 04:41 PM
  3. Citrix failing to map local printer
    By Andi in forum Thin Client and Virtual Machines
    Replies: 0
    Last Post: 23rd September 2008, 12:19 PM
  4. Replies: 5
    Last Post: 14th June 2008, 01:18 AM
  5. Replies: 21
    Last Post: 11th July 2006, 08:37 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •