Installing a Network Printer Remotely

I'm trying to write a script to automatically add a printer to client XP machines. This script works: rundll32 printui. dll,PrintUIEntry /if /b Test Printer /f \\XXX. XX. XXX. XX\download\4600driver\hp4600p6.

Everything New Technology 1823 This topic was started by ,


data/avatar/default/avatar34.webp

198 Posts
Location -
Joined 2001-06-03
I'm trying to write a script to automatically add a printer to client XP machines.
 
This script works:
 
rundll32 printui.dll,PrintUIEntry /if /b "Test Printer" /f \\XXX.XX.XXX.XX\download\4600driver\hp4600p6.inf /r "lpt1:" /m "HP Color LaserJet 4600 PCL 6" /Z
 
But I want to change the port from "lpt1:" to an IP address. Anyone know the syntax to do this? I've tried "IP_XXX.XX.XXX.XX", but I get a "the arguments are invalid" error after Windows starts copying files and the printer does not show up in the printers folder.

Participate on our website and join the conversation

You have already an account on our website? Use the link below to login.
Login
Create a new user account. Registration is free and takes only a few seconds.
Register
This topic is archived. New comments cannot be posted and votes cannot be cast.

Responses to this topic


data/avatar/default/avatar34.webp

198 Posts
Location -
Joined 2001-06-03
OP
Yes and no... I fought with this for a long time, but I got it to work. I bundled all the scripts into an EXE that can be placed in a user's Run at First/Next Logon or installed manually.
 
This script will map a shared printer to a virtual network port:
 
**********************************************************
@echo off
 
NET USE LPT3: /DELETE
 
NET USE LPT3: "\\XXX.XX.XXX.XX\PSB Color Laser Printer" PrintOnlysPassword /user:YourDomain.local\printonly /PERSISTENT:YES
 
MKDIR "C:\documents and settings\all users\start menu\Programs\Startup"
 
COPY mapLPT3.bat "C:\documents and settings\all users\start menu\Programs\Startup"
 
rundll32 printui.dll,PrintUIEntry /if /b "IES Color Laser Printer" /f \\XXX.XX.XXX.X\download\4600driver\hp4600p6.inf /r "lpt3:" /m "HP Color LaserJet 4600 PCL 6" /Z
***********************************************************
 
Then the mapLPT3.bat file that restores the printer port mapping on reboot:
 
******************************************************
@ECHO OFF
 
NET USE LPT3: /DELETE
 
NET USE LPT3: "\\XXX.XX.XXX.X\PSB Color Laser Printer" PrintOnlysPassword /user:YourDomain.local\printonly /PERSISTENT:YES
******************************************************
 
I had to map to a share instead of an IP port, because Windows will not let you map an IP port that does not already exist on the system. Since you have to map to a share, you need to use a valid domain account to authenticate against the share.
 
It has some problems though:
 
1. Unsecured domain account and pwd floating around - anyone who digs out the userID and pwd from the files will be able to log in as a user at any workstation on the domain. I packaged the files into self-extracting .EXE's so that it won't be obvious to most users. I tried for weeks to set Active Directory so that it will "Deny Interactive Logon" for the printonly account/security group/OU, but it had no effect no matter what I did.
 
2. Only works with English installs of Windows.
 
3. Not backwards compatible with 98 clients.
 
Don't know if this will help, but it might give you some ideas.
 
 

data/avatar/default/avatar17.webp

2 Posts
Location -
Joined 2004-11-10
All great, but I really want to add a printer with its IP-address, to unload an old server. I'll try to get permission to use group policies instead or something..
 
Tnx anyway!

data/avatar/default/avatar34.webp

198 Posts
Location -
Joined 2001-06-03
OP
There is a reason for the IP address in the path to the printer (at least for my organization) My script was written mostly for visiting scientists who use the network, but do not log onto the domain. As such, sometimes non-domain Windows clients get pissy about resolving the server's name (05ies) Mapping to the IP address\share just makes things easier in that respect.