Create a local port for a printer

放肆的年华 提交于 2019-12-13 07:31:05

问题


I am trying to make a installer for a printer driver. for that i need to create a port. for network printers I could create a port by using 'prnport.vbs'.

cscript c:\Windows\System32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r [PORTNAME] -h [IPADDRESS] -o raw

But this script cannot create a local ports.

I sow this post but it seems not work for Win7.

Can anyone direct me to a cmd or C# solution to create a local port.


回答1:


Found a solution from here. And it works for me. I put this as a answer for any one have same problem and missed that post.




回答2:


For which Windows versions?

With PowerShell

Add-PrinterPort -Name "NameYourLocalPort:"

With Windows API

AddPrinter function



来源:https://stackoverflow.com/questions/45950062/create-a-local-port-for-a-printer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!