Jump to content

Recommended Posts

Posted

Is it possible to create a VB script to install a local TCP/IP port printer on a machine and have it pop up asking for the IP when its installing it?

 

I have say 10 models of printers all over the place and what I want to do is create a script for each model with reference to where the drivers are and then just enter the IP when I run this script, is this possible?

Posted

Here is a script I use

 

(This bit all on one line)

 

rundll32 printui.dll,PrintUIEntry /ga /c\\computername /n\\servername\printername

 

 

 

sc \\computername stop spooler

 

sc \\computername start spooler

 

 

 

Change the computer name, server name and printer name. You can add as many as you like as long as there is a gap between each "start spooler" command.

 

 

 

To remove a printer just change ga to gd in the script. This will add or delete the printer for all users.

Posted
It would be but we don't have access to that and machines are generally still XP. It is not my network so literally have a login with local admin rights.
  • 2 weeks later...
Posted

Something like this is a start. Enjoy

 

Dim strIP

strIP = InputBox ("Enter TCP/IP Printer Port IP Address")

CreatePort(strIP)

 

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

 

Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

objPrinter.DriverName = "HP LaserJet 4250 PCL6"

objPrinter.PortName   = "IP_" & strIP

objPrinter.DeviceID   = "Printer Name"

objPrinter.Location = "Location"

objPrinter.Put_

 

Function CreatePort(pName)

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNewPort = objWMIService.Get _

    ("Win32_TCPIPPrinterPort").SpawnInstance_

objNewPort.Name = "IP_" & pName

objNewPort.Protocol = 1

objNewPort.HostAddress = pName

objNewPort.PortNumber = "9100"

objNewPort.SNMPEnabled = False

objNewPort.Put_

EndFunction

  • Thanks 1
Posted

Exactly what I am after but what happens if it is a printer which the client doesn't have the drivers on and they are in the folder?

 

I suppose the way of doing it is add the drivers and then add printer but I was hoping for a one stop script. mac_shinobi has given me a script which I am have not had chance to try yet but what you have put bainer is what I am after except that the drivers are not part of Windows.

Posted

You're right, you need to get the driver installed first, are you wanting this in the same script? Just that this would require a lot of editing each time you use a new driver. What might be a good option was to build a driver catalogue. This could just be a text or csv on a file share. The script would build an array of installed drivers on the client and compare the list with the central catalogue. If one is missing on the client, the driver could be installed, then the printer added.

Does this sound like the kind of thing your looking for?

Posted

I am more after just a single click prompt for IP address and it installs it. Don't mind having a script for each model as it will save me lots of time.

 

I have got a script but I haven't had time to test it yet, this was given to me by another user on here. It's one of those things I am doing in my space time.

Posted

Would Printer Migrator not be a better alternative?

 

I use it all the time as it saves me so much hassle. The drivers and ports are contained within a cab file and you can install the printers in less than a minute. If you want more info let me know.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...