Solved

Printer script

Posted on 2007-11-29
6
235 Views
Last Modified: 2010-04-16
It is quite common that we have to install printers for our users on a daily basis.

All the printers are HP and have a IP address assigned to them.

Is it possible to create a script that you could run on an individuals machine that would install a particular printer with the correct IP?

The drivers are located on the server so the files could be taken from there. I understand that you would probably need a script for each model but this would save us a lot of time in the future.

Is it possible? Can anyone create a script for this?

Many thanks in advance.
0
Comment
Question by:ZEDA_ISG
  • 3
  • 2
6 Comments
 
LVL 27

Expert Comment

by:michko
ID: 20373335
0
 

Author Comment

by:ZEDA_ISG
ID: 20394869
Thank you for the reply.

I was actually looking for a printer script that would assign the IP address of the printer, not a script where it looks for it on the servre, i.e.:

WSHNetwork.SetDefaultPrinter "\\ServerName\PrinterName"
    End Select

The process I would like to be created by a script (if possible) is this process:

Add Printer > A local printer > Create New Port > Standard TCP/IP Port

The script will then assign the correcr IP for this printer and install the printer drivers
0
 
LVL 27

Accepted Solution

by:
michko earned 500 total points
ID: 20395213
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:ZEDA_ISG
ID: 20412263
The above links didn't actually work but part of it was amended to make it work.

This may help someone else.

Here is the script I have got to work:

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

set objNewPort = objWMIService.get("Win32_TCPIPPrinterPort").SpawnInstance_
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True
Set objDriver = objWMIService.Get("Win32_PrinterDriver")

objDriver.Name = "HP LaserJet 2100 Series PS"
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
objDriver.FilePath = "\\servername\drive\Drivers\PrintDrivers\HP\HP 2100TN PS"
objDriver.Infname = "\\servername\drive\Drivers\PrintDrivers\HP\HP 2100TN PS\HP2100PS.INF"
intResult = objDriver.AddPrinterDriver(objDriver)


'Installs Printer Port
objNewPort.Name = "PRINTERNAME"
objNewPort.Protocol = 1
objNewPort.HostAddress = "172.16.xx.xxx"
objNewPort.PortNumber = 9100
objNewPort.SNMPEnabled = True
objNewPort.Put_


'Install Printer
objPrinter.DriverName = "HP LaserJet 2100 Series PS"
objPrinter.PortName = "PRINTERNAME"
objPrinter.DeviceID = "PRINTERNAME"
objPrinter.Put_
0
 
LVL 27

Expert Comment

by:michko
ID: 20412309
I've found most scripts need some "tweaking" for an individual location/functionality.  Glad I was able to refer you to some that were adaptable to your circumstances.

michko
0
 

Expert Comment

by:khela
ID: 21956152
Hi there ZEDA_ISG

is the above script working for remote computers??
espacially this part that i'm intrested to know if it's working or not

objDriver.FilePath = "\\servername\drive\Drivers\PrintDrivers\HP\HP 2100TN PS"
objDriver.Infname = "\\servername\drive\Drivers\PrintDrivers\HP\HP 2100TN PS\HP2100PS.INF"

did that manage to install the printer driver on a remote computer?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to count occurrences of each item in an array.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now