g9194
asked on
Printer setup script / utility for "local printer" on TCP/IP port in Windows (non-domain) - remove conflicts then add port and printer
Does anyone know of a utility (or does anyone know how to write a script) that can work on Windows 7 and Windows XP (it could be two separate utilities/scripts) and can:
1) Remove any TCP/IP printer ports on a given IP address
2) Add a new TCP/IP printer port on that IP address
3) Add the printer on that port and install the driver from a network path to a .inf file
You can assume the script will be run as administrator.
If it relies on a utility, ideally it would be one that comes installed with Windows, but if not that might still be fine.
This is not being used on a Windows domain, so unfortunately some potentially easy solutions along those lines aren't available.
1) Remove any TCP/IP printer ports on a given IP address
2) Add a new TCP/IP printer port on that IP address
3) Add the printer on that port and install the driver from a network path to a .inf file
You can assume the script will be run as administrator.
If it relies on a utility, ideally it would be one that comes installed with Windows, but if not that might still be fine.
This is not being used on a Windows domain, so unfortunately some potentially easy solutions along those lines aren't available.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It looks like -d will allow deletion of a port, but when I tried it, it gave me an error. I'm wondering if the printer needs to be removed first so it's not using that port. If that's it, how can I have it accomplish that - is there something that will automatically delete the port and printer on a certain IP?
cscript //NoLogo delete_port.vbs -d -r "192.168.1.200"
Unable to delete port Error 0x80041001 Generic failure
Operation DeleteInstance
Provider Win32 Provider
Description The requested resource is in use.
cscript //NoLogo delete_port.vbs -d -r "192.168.1.200"
Unable to delete port Error 0x80041001 Generic failure
Operation DeleteInstance
Provider Win32 Provider
Description The requested resource is in use.
Yes. Try deleting the printer first and then deleting the port that printer was using.
cscript //NoLogo prnmngr.vbs -d -p "Name of the Printer to Delete"
ASKER
Hmm... the script won't necessarily know the name of the printer - it needs to be able to delete it by IP address. Should I close this question and give partial points and then open a separate question?
Do you really need to delete the TCP/IP port?
The name of the printer is required in order to target it for management.
To delete the TCP/IP port you'll have to free up the port by, 1. changing the port that the printer is using to something else:
or 2. deleting the printer:
BTW, once you add a new printer, if you want to make it the "Default" you can use the following code in your .vbs script:
The name of the printer is required in order to target it for management.
To delete the TCP/IP port you'll have to free up the port by, 1. changing the port that the printer is using to something else:
cscript //NoLogo prncnfg.vbs -t -p "Printer Name" -r "IP_192.168.1.101"
or 2. deleting the printer:
cscript //NoLogo prnmngr -d -p "printer name"
BTW, once you add a new printer, if you want to make it the "Default" you can use the following code in your .vbs script:
Set WSHNetwork = CreateObject("WScript.Network")
WSHNetwork.SetDefaultPrinter "HP LaserJet 5Si"
ASKER
I think I do need to delete it to prevent a conflict.
If you don't know how to delete a printer and port given ONLY an IP address, that's ok - I might be able to take the help you gave me so far and then ask that as a separate question.
Thanks!
If you don't know how to delete a printer and port given ONLY an IP address, that's ok - I might be able to take the help you gave me so far and then ask that as a separate question.
Thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah, maybe there isn't one. I guess I just assumed you couldn't have two on the same port. I'll go ahead and accept your answers. Thanks for the help!
ASKER
I felt like there could have been better reading done so that so much back and forth wasn't required, but overall I was happy with the help that was provided.
ASKER