Options

Issue installing printer via command line on Vista/Win7.

msteinhilbermsteinhilber Member Posts: 1,480 ■■■■■■■■□□
Hoping somebody may have run into this before and might have some advice. I'm writing a small app with a basic GUI for end users to use to install common applications as well as map network drives and install printers. Our end users are real estate agents who come and go frequently and for that amongst other reasons I do not have the option to join them to our domain, hence why I'm writing this app to assist setting up their machines initially and as they move about from office to office and need to add or remove printers.

Anyways, some of our offices that are smaller do not have a print server so we have them print direct to the printer via IP. I have my app execute the following commands for each printer they select a checkbox for:

cscript %windir%\System32\Printing_Admin_Scripts\en-US\Prnport.vbs -a -r IP_x.x.x.x -h x.x.x.x
printui.exe /if /b "printer name" /f "driver location" /r "port name" /m "driver name"

The above works flawless in all my Vista and Windows 7 test VM's I've tried it on the first time I execute it. However, if I delete the printer either via Windows (right click, remove device) or via command line and then attempt to run the same commands again to reinstall it - it errors out "operation could not be completed (error 0x00000704), The specified port is unknown." The port is created, I can look at the print server properties in my virtual machine and see the port was successfully added and if I manually add a printer, select the existing local tcp/ip port and then direct it to the same driver location specified in my printui.exe command it created the printer and works fine. If I revert my VM's to a snapshot prior to executing the printer install via command line the first time, I can go ahead and execute the commands one time for a successful install and once again reproduce the same problem if I remove the printer and try to install it again.

Any ideas? I've been trying to work around this part of yesterday afternoon and all of this morning with no success and my Google-fu has lead me nowhere. My Windows XP VM's do not exhibit the same trouble, I can remove the printers either manually or via command line and reinstall them via command line without issue.

Comments

  • Options
    msteinhilbermsteinhilber Member Posts: 1,480 ■■■■■■■■□□
    Well don't I feel like a fool, wasted all this time working in VM's to test and figured I would see how it behaves on physical machines... worked just fine. Became so complacent testing things out within a VM that it took me many hours of testing within a VM until a co-worker randomly asked how it performed on a physical machine...
Sign In or Register to comment.