问题
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