Delete Printer Connections using PrintUI gives error Unable to delete the per machine printer connection. Operation could not be completed (error 0x0000071a)
-
Friday, January 18, 2013 8:02 PM
I'm attempting to use the PrintUI DLL (printui.exe) to add and delete per-machine printer connections shared by a domain member print server to/from domain client computers. But I randomly (25% of the time) get the error "Unable to delete the per machine printer connection. Operation could not be completed (error 0x0000071a)." Code 0x0000071a may mean "The remote procedure call was cancelled" (RPC_S_CALL_CANCELLED). However it means nothing to me and I do not understand why the RPC would fail on some attempts, but work on subsequent attempts.
- Print server is Windows 2008 R2 SP1 with the latest recommended hotfixes.
- Clients are Windows XP SP3 or Windows 7 SP2 with the latest recommended hotfixes.
Seemingly very inexplicably and randomly our support stafff get these errors when they run the script to add or remove printers. It does not matter which printer server or printer share (I have multiple print servers and printers).
I am adding and deleting the connections in a command script using these commands:
Add: RUNDLL32 PRINTUI.DLL PrintUIEntry /ga /c\\%1 /n%2 /Gw >> %3
Delete: RUNDLL32 PRINTUI.DLL PrintUIEntry /gd /c\\%1 /n%2 /Gw >> %3
I have tried adding print spooler restarts before or after the PRINTUI commands, but this does not seem to help. In fact, if I add the spooler restart it seems like I increase the failure rate on Windows 7 clients and decrease the failure rate on Windows XP clients.
I have even tried to circumvent the problem by deliberately attempting to add or delete an invalidly named printer share ("\\DoesNotExist\IgnoreError") but this throws a pop-up error message which must be clicked "OK" to bypass. That error message is "Unable to add the per machine printer connection. The local print spooler service is not running. Please restart the spooler or restart the machine." Which is an incorrect error and has nothing to do with an incorrectly named print server share in the add or delete commands of PRINTUI.
All Replies
-
Friday, January 18, 2013 11:03 PM
Also tried the following additonal PRINTUI command options, no effect:
RUNDLL32 PRINTUI.DLL PrintUIEntry /ga /c\\computer /n\\server\prtshare /u /Gw /q
RUNDLL32 PRINTUI.DLL PrintUIEntry /gd /c\\computer /n\\server\prtshare /u /Gw /q
Running the enumerate /ge confirms when the add /ga or delete /gd fails.
RUNDLL32 PRINTUI.DLL PrintUIEntry /ge /c\\computer
-
Saturday, January 19, 2013 4:27 AM
A printqueue, stored as \\printserver\printer_share is stored per user.
If it's by an IP queue or a local port then it's per machine.
My first idea is that your script run in the machine context when there is no printer available to erase, or the one you want to erase is not yet ready to delete (the user profile is not loaded yet in exemple)
I would create a GPP that erase all printqueue in worst case or make your script run in the correct context
MCP | MCTS 70-236: Exchange Server 2007, Configuring
Twitter - @yagmoth555 (
)
Blog: http://www.jabea.net | http://blogs.technet.com/b/wikininjas/- Edited by Yagmoth555 Saturday, January 19, 2013 4:28 AM
-
Tuesday, January 22, 2013 4:25 PM
Thanks Yagmoth, but perhaps you misunderstand how per-machine printer connections work - I do not either!! But I know only there are some registry entries (and possibly other internal structures) and are in an available state. When a new user profile is created the printers are automatically copied over into the user profile. You can see it happen within 30 seconds of a new user account logging in. Just open control panel item Devices and Printers and see the printer objects magically populate.
For example, we can begin with a fresh Windows 7 image (containing no previously logged on user profiles), add per-machine printer connections, and then when the computer is deployed to the end user, the user profiles all get the same printers. The only way to add, delete, or enumerate these printer connections is using the PRINTUI /ga, /gd, /ge commands.
What is strange is that they work "most of the time". There does not seem to be any rhyme or reason to why they fail and why WinXP seems to have a slightly higher failure rate. Looking for someone with clear experience with PRINTUI /ga /gd and how they handle this intermittent problem....
- Edited by George Perkins Tuesday, January 22, 2013 9:19 PM typo
-
Thursday, January 24, 2013 1:39 AM
I'am more used to GPP, can you make 2 GPO maybe. a GPO with GPP that erase all printer, and one that add some with tcp/ip printqueue, or \\printserver 's way ?
MCP | MCTS 70-236: Exchange Server 2007, Configuring
Twitter - @yagmoth555 (
)
Blog: http://www.jabea.net | http://blogs.technet.com/b/wikininjas/ -
Friday, January 25, 2013 9:37 AM
Hi George,
how do you run those commands, at logon script, manually on local machines or remotely?
It seems like RPC issue, try to turn async RPC off as a test. (this 'Enabled protocols = 6' thing)
-
Friday, January 25, 2013 5:01 PM
Yagmoth,
This is a question about PRINTUI DLL. I am not using Group Policy or Group Policy Preferences.
(We did look into using GPP for our printing needs, but our unique requirements can't be met thru GPP. I need to get PRINTUI DLL to work consistently).
-
Friday, January 25, 2013 5:09 PM
Sergey,
Thanks for the reply. I have implemented my PRINTUI DLL commands in a simple command script. But it does not have to be a script, the command can be entered from a command prompt directly (and still fails):
RUNDLL32 PRINTUI.DLL PrintUIEntry /ga /c\\computer /n\\server\prtshare /u /qRUNDLL32 PRINTUI.DLL PrintUIEntry /gd /c\\computer /n\\server\prtshare /q
I get about a 75% success rate. If I restart the print spooler service on WinXP target computers that success rate improves. But for Windows 7 target computers, restarting the print spooler seems to have no effect. Adding the /q removes the error message "Unable to delete the per machine printer connection. Operation could not be completed (error 0x0000071a)" from being displayed. But does not help the success rate of the command. I have been using multiple computers for my testing. It seems to make no difference which computer is successful or fails and is random. Restarting the computer does not help.
I did some searching on your idea of async RPC protocol, found a hotfix in fact (http://support.microsoft.com/default.aspx?scid=kb;en-US;2388142) but that does not apply to this situation. The async RPC feature came out with Vista/2008 and is only a problem when these newer OSes try to connect to a Windows 2003 print server. My print server is Windows Server 2008 R2. Is there something more specific you had in mind with your suggestion? I am open to this being an async RPC issue, but would like to understand how that would apply in this case.
- Edited by George Perkins Friday, January 25, 2013 5:11 PM add detail
-
Friday, January 25, 2013 8:58 PM
I noticed another symptom of the "random" failures (and I see this if I attempt to enumerate the printer connections using /ge option) is the following error message:
"Unable to enumerate per machine printer connections. The local print spooler service is not running. Please restart the spooler or restart the machine."
In fact, the spooler service is running. Restarting the spooler does not help.
-
Saturday, January 26, 2013 4:17 AM
Yagmoth,
This is a question about PRINTUI DLL. I am not using Group Policy or Group Policy Preferences.
(We did look into using GPP for our printing needs, but our unique requirements can't be met thru GPP. I need to get PRINTUI DLL to work consistently).
I tried to help, if way A does not work I tried to find a way B.
Thanks Yagmoth, but perhaps you misunderstand how per-machine printer connections work - I do not either!! But I know only there are some registry entries (and possibly other internal structures) and are in an available state. When a new user profile is created the printers are automatically copied over into the user profile.
You misunderstood me too; my point was, how in a computer startup script you can erase a network printqueue ? It's not classified as a per-machine connection. Only IP, USB, etc.. are per-machine.
http://technet.microsoft.com/en-us/library/cc775560(v=ws.10).aspx -
Configuration Preferences Stored in the Registry Hive
The NTuser.dat file contains the following configuration settings:
- Windows Explorer settings. All user-definable settings for Windows Explorer, as well as persistent network connections.
- Taskbar settings.
- Printer settings. All network printer connections.
"RUNDLL32 PRINTUI.DLL PrintUIEntry /ga /c\\computer /n\\server\prtshare /u /Gw /q" can't work unless you are logged in the account that got the connection done to the printer.
Printer share are per-user ACE.
For the 30 second timeout, it's just the time the spooler load all driver and such for available printqueue to the user. So do you push printer before deleting's some ? Where you load that script, in the user or machine's context ???
And most of all, never forget that the rundll you use simulate a click in the control panel -> device section. If the printer does not show in the control panel at first, then when you click the script nothing will be done.
Last point, if the script bug your Win7 computer, then I would look to be sure it's not a faulty driver, causing your script to fail more. (the fact that you got to reload the local spooler to make the script work make me think of a bad driver too)
MCP | MCTS 70-236: Exchange Server 2007, Configuring
Twitter - @yagmoth555 (
)
Blog: http://www.jabea.net | http://blogs.technet.com/b/wikininjas/ -
Saturday, January 26, 2013 7:42 PMAnswerer
Hi George, I see we had a detailed conversation on the per machine connections with printui a few months ago.
Printui pops the General error dialog when something fails but it does not know why. The RPC cancelled error is from the remote machine. Either the spooler is busy but for busy I expect 1723, or not reachable.
C:\>winerror 0x6bb
1723 RPC_S_SERVER_TOO_BUSY <--> 0xc0020018 RPC_NT_SERVER_TOO_BUSYC:\>winerror 0x71a
1818 RPC_S_CALL_CANCELLED <--> 0xc0020050 RPC_NT_CALL_CANCELLEDFrom my previous post you enabled the remote RPC endpoint so that's not going to be the issue. You can verify the spooler service is running on the client using the sc.exe command. I assume the spooler is typically running but you can start it with the sc command as well. The RPC error could also be network latencies. PS you can absolutely add a bogus print share "printui /ga /n\\Yagmoth555\Perkins /u /Gw /q" I'm at home and don't have a remote target.
C:\>sc \\clientPC query spooler
SERVICE_NAME: spooler
TYPE : 110 WIN32_OWN_PROCESS (interactive)
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0Alan Morris Windows Printing Team
- Marked As Answer by George Perkins Tuesday, January 29, 2013 4:21 PM
-
Tuesday, January 29, 2013 4:07 PM
Yagmoth,
This is a confusing subject, there are local printers (which can use a print server as the port), and there are per-machine and per-user printer connections. Your references are for local printers, and I am working with per-machine printer connections. Unfortunately, this is not at all well documented by Microsoft and the only way to get it is by trial and error. Alan Morris' response below triggered the right troubleshooting for me, and I found a solution.... Thank you.
George
- Edited by George Perkins Tuesday, January 29, 2013 4:08 PM typo
-
Tuesday, January 29, 2013 4:27 PM
Alan,
Thanks, with more care regarding the status of the Spooler service I have improved the success rate for PRINTUI DLL /ga, /gd, /ge commands.
If I query the spooler service I can see it is in the running state, but sometimes the spooler is not ready or the remote computer does not respond fast enough or with certain qualities that PRINTUI is expecting. PRINTUI does not have an exit code to check to determine if it has been successful, so there is no guarantee that it acts as I intend. I have concluded PRINTUI is not designed for scripting. (Even the name hints at that.)
I have improved the success rate by including a check to determine the remote computer spooler service is "running" and then also adding delays in the script in an effort to slow down script processing. I have also discovered that Windows XP spooler service must be restarted to implement PRINTUI changes while in Windows 7 the spooler does not need a restart.
- Edited by George Perkins Tuesday, January 29, 2013 4:28 PM clarity
-
Tuesday, January 29, 2013 9:51 PMAnswerer
George, thanks for the polite comments. I am sure that Yagmoth appreciates the opportunity to learn more on all subjects. I'm glad you were able to get a mainly working solution. XP requires a spooler restart for the /ga per machine connections. Win7 will need this at times but if it's working without logoff / logon leave it be.
Alan Morris Windows Printing Team
-
Wednesday, January 30, 2013 12:41 AM
Thanks for the information ! I tend to be too direct sometime, but as Iam french I try to talk to the goal directly (to prevent typo and such) So sorry If I sounded not good too. (But yes, I was in the spirit that only local and network pritnqueue exist, so my error there !)
Alan, that make me wonder to something else. I seen a lot of issue in the forum that printjob are logged as MACHINE$ and not username, and I was in the spirit that the remote spooler only accept user credential, that mean that it actually accept machine account's too ? (and if in a shop that does not use per-machine connection, we could remove that spooler feature, that mean we will have an aswer to all those bugs)
MCP | MCTS 70-236: Exchange Server 2007, Configuring
Twitter - @yagmoth555 (
)
Blog: http://www.jabea.net | http://blogs.technet.com/b/wikininjas/- Edited by Yagmoth555 Wednesday, January 30, 2013 12:46 AM

