RickBock
asked on
Using VB6 to change printer port TCP/IP address
Greetings one and all,
I've had another "we must have this by Monday or the world will end" thing dropped in my lap. We have a client with numerous offices all equipped with the same printer. All of the offices are connected via VPN and we know the IP addresses of all of the printers.
Since these printers are almost always used locally - that is only by the people in each specific office, they haven't been set up as network printers on the server in the main office which would greatly simplify things.
Our client has an occasional need to print documents on every printer at more or less the same time. My thought was to create a new local TCP/IP printer on a work station, then use a small VB6 program to load the document to be printed, then run through the list of IP addresses, change the printer port, print the document and continue looping.
The trouble is I can't really find anything that explains how to change a printer port short of opening the port editor and doing it by hand.
Can anyone suggest a way of doing this?
I've had another "we must have this by Monday or the world will end" thing dropped in my lap. We have a client with numerous offices all equipped with the same printer. All of the offices are connected via VPN and we know the IP addresses of all of the printers.
Since these printers are almost always used locally - that is only by the people in each specific office, they haven't been set up as network printers on the server in the main office which would greatly simplify things.
Our client has an occasional need to print documents on every printer at more or less the same time. My thought was to create a new local TCP/IP printer on a work station, then use a small VB6 program to load the document to be printed, then run through the list of IP addresses, change the printer port, print the document and continue looping.
The trouble is I can't really find anything that explains how to change a printer port short of opening the port editor and doing it by hand.
Can anyone suggest a way of doing this?
There is some info about how to setup printer ports using registry keys here as well:
http://users.telenet.be/mydotcom/howto/scripts/sysadmin/printers_tcpip.htm
http://users.telenet.be/mydotcom/howto/scripts/sysadmin/printers_tcpip.htm
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Could you not create a print queue for each printer on the workstation then cycle through the printers one at a time sending the jobs as required. Not sure why you feel you need to use only a single queue ... this approach would mean your program having to wait around for the job to finish before spooling the next print ... just in case the printer was out of toner or paper.
Priz
Priz
ASKER
Unfortunately as it's been explained to me most of the offices are borderline standalone - they access an intranet but not the domain itself so anything based off the domain is problematic. Also there are potentially hundreds of locations so we'd wind up adding hundreds of printers which would be used once a month at best.
I have looked at the port information from that page, but in my experimentation - manually altering the IP address in
HKEY_LOCAL_MACHINE\SYSTEM\ ControlSet 001\Contro l\Print\Mo nitors\Sta ndard TCP/IP Port\Ports\
But nothing changes.
I have looked at the port information from that page, but in my experimentation - manually altering the IP address in
HKEY_LOCAL_MACHINE\SYSTEM\
But nothing changes.
ASKER
Priz,
It's the volume of printers that would have to be set up on the workstation that's the main concern, plus as new offices come online - or less importantly go office, it's much simpler to add or remove an IP address from a table than have to add or delete additional printers.
At least that's the theory <g>
It's the volume of printers that would have to be set up on the workstation that's the main concern, plus as new offices come online - or less importantly go office, it's much simpler to add or remove an IP address from a table than have to add or delete additional printers.
At least that's the theory <g>
For TCP/IP printing domain security should not be an issue. Hundreds of printers would most definitely slow down whatever workstation you run this application on.
With respect to changing the registry key ... you may need to stop and restart the TCP/IP print service and/or print spooler to refresh the connection information between prints.
Priz
With respect to changing the registry key ... you may need to stop and restart the TCP/IP print service and/or print spooler to refresh the connection information between prints.
Priz
ASKER
No joy. In brief here's what I'm doing:
I've got two identical test printers at 192.168.1.230 and .231. I've set up an IP printer port at 192.168.1.230 names portTest, and a printer pointing at that port named printTest. I'm able to print a test page to printTest and if comes out as expected on the printer at .230
First off I tried changing:
HKLM\SYSTEM\ControlSet001\ Control\Pr int\Monito rs\Standar d TCP/IP Port\Ports\portTest\Hostna me = 192.168.1.231
and
HKLM\SYSTEM\ControlSet001\ Control\Pr int\Monito rs\Standar d TCP/IP Port\Ports\portTest\IPAddr ess = 192.168.1.231
And tried printing but the test page still showed up at .230.
Next I restarted the spooler and tried a test print. No I get no pages and no errors.
Editing the printer from the control panel, then configuring the port I can change the IP address back to 230, then do a test print and it prints fine.
Repeating these steps to change the IP address to .231 and running a test print and I get nothing again.
Restarting the spooler and running a test page with the port IP address still set to .231 through the Configure Port window results in nothing printed.
Changing the IP address back to 230 in the Configure Port window and printing a test page gets me a page printed.
I'm only finding references to the port name in
HKLM\SYSTEM\ControlSet001\ Control\Pr int\Printe rs\PrintTe st
Nothing specifying the IP address.
Should I be looking elsewhere for the port addresses? If it's pertinent I'm on Win 7 at the moment. I don't know for certain what OS this will be installed under.
Thanks
I've got two identical test printers at 192.168.1.230 and .231. I've set up an IP printer port at 192.168.1.230 names portTest, and a printer pointing at that port named printTest. I'm able to print a test page to printTest and if comes out as expected on the printer at .230
First off I tried changing:
HKLM\SYSTEM\ControlSet001\
and
HKLM\SYSTEM\ControlSet001\
And tried printing but the test page still showed up at .230.
Next I restarted the spooler and tried a test print. No I get no pages and no errors.
Editing the printer from the control panel, then configuring the port I can change the IP address back to 230, then do a test print and it prints fine.
Repeating these steps to change the IP address to .231 and running a test print and I get nothing again.
Restarting the spooler and running a test page with the port IP address still set to .231 through the Configure Port window results in nothing printed.
Changing the IP address back to 230 in the Configure Port window and printing a test page gets me a page printed.
I'm only finding references to the port name in
HKLM\SYSTEM\ControlSet001\
Nothing specifying the IP address.
Should I be looking elsewhere for the port addresses? If it's pertinent I'm on Win 7 at the moment. I don't know for certain what OS this will be installed under.
Thanks
Have you tried using CurrentControlSet rather than ControlSet001??
I am working on XP at the moment ... on this PC I can see the IP address of a TCP/IP printer I have installed in HKLM\System\CurrentControl Set \ControlPrint\Monitors\Sta ndard TCP/IP Port\Ports\<name of port>\IPAddress
Hope this helps
Priz
I am working on XP at the moment ... on this PC I can see the IP address of a TCP/IP printer I have installed in HKLM\System\CurrentControl
Hope this helps
Priz
ASKER
Same results. Perhaps it wasn't poor search phrases that kept me from finding any references to this after all.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
I think I've found a solution - it's not pretty but I won't tell if you won't. I ran across an old VB script called prnport which allows me to make the necessary changes via the following command line
cscript prnport.vbs -t -r testPort -h 192.168.168.231
I just have to shell it to a command line and wait a few seconds before trying to print.
I'll get pretty with version 2 when I have more than one working days notice <g>
Thanks for the help guys!
cscript prnport.vbs -t -r testPort -h 192.168.168.231
I just have to shell it to a command line and wait a few seconds before trying to print.
I'll get pretty with version 2 when I have more than one working days notice <g>
Thanks for the help guys!
ASKER
I've included my comment about the VB script since that's how I'm getting this thing to work but wouldn't have come up with it if I wasn't bouncing ideas around.
http://technet.microsoft.com/en-us/library/cc754699.aspx