MatthewL Posted April 9, 2013 Posted April 9, 2013 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?
bclarke Posted April 9, 2013 Posted April 9, 2013 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.
bclarke Posted April 9, 2013 Posted April 9, 2013 Just re-read your post, probably not what you are after but is good for network printer deployment.
mac_shinobi Posted April 10, 2013 Posted April 10, 2013 (edited) Sent email and pm @MatthewL - Just wondering would Group Policy Preferences not be an option ( not sure what Server OS'es you are using / have ) ?? Link that I can find ( Printer Manager as maybe a 2nd option ) - http://technet.microsoft.com/en-gb/library/cc753109%28v=ws.10%29.aspx Edited April 10, 2013 by mac_shinobi
MatthewL Posted April 10, 2013 Author Posted April 10, 2013 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.
bainer Posted April 23, 2013 Posted April 23, 2013 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_ End Function 1
MatthewL Posted April 23, 2013 Author Posted April 23, 2013 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.
bainer Posted April 30, 2013 Posted April 30, 2013 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?
MatthewL Posted April 30, 2013 Author Posted April 30, 2013 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.
LeightonJames Posted May 1, 2013 Posted May 1, 2013 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.
MatthewL Posted May 1, 2013 Author Posted May 1, 2013 Never thought of that, might have a look at that.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now