locked
XP Per-Machine Printer Connections RRS feed

  • Question

  • Hi -

    I am having inconsistent results on XP machines when using 

    rundll32 printui.dll,PrintUIEntry /ga /n\\{PrintServer}\{PrinterShare}

    on a "Computer Startup Script"

    It seems to work just fine on some XP machines while on others HKLM\..\Printer\Connections reg key is never populated and users never get the printers.

    The funny thing is that if we then manually run the command above remotely (adding /c\\{TargetComputer} of course), user gets the printers on the next reboot (which kinda makes me wonder whether the spooler service is not ready at the time the command is issued).

    I am stumped and need help with troubleshooting this. I'm happy to see Alan Morris from Printing team is lurking around here and maybe will respond ;)

    I am copy/pasting the lines that matter from the vbscript.

    for each PrinterGroup in arrPrinterGroups
    arrGroup = Split(PrinterGroup,".")
    ' skipping first 2 grp and prn as groups are named grp.prn.ServerName.PrinterName
    Server=arrGroup(2)
    Printer=arrGroup(3)
    cmdConnectPrinter="cmd /c rundll32 printui.dll,PrintUIEntry /ga /n\\" & Server & "\" & Printer
    ' Hide Window and return immediately without waiting
    oShell.Run cmdConnectPrinter,0,false
    Next 

    Thanks

    Update - 2013-08-11

    I used Procmon boot-logging feature to trace what's happening. Here are a few things I noticed.

    Wscript.exe -> cmd.exe This seems to work OK. In other words, every time wscript.exe tells cmd.exe, a process is created.

    cmd.exe ->rundll32.exe This seems to work each time too. Although Procmon's command line column sometimes does not show the command line, but that proved to be a red-herring.

    What I noticed was that when rundll32.exe returned with exit status 0, printer connection was added to:

    HKLM\System\CurrentControlSet\Control\Print\Connections

    but sometimes it returned 258 (Yes, I heard that it does not return anything too, but that's what Procmon claims). When that happens, connection is not created.

    I guess question is, what causes rundll32 to return 258?  

    I also ran procmon when issuing /ga, /gd options and followed the sequence of events happening afterwards. I won't go into details here, but it seemed that all that command is doing is to create a connection (in the form of ,,PrintServer,Printer) under the reg key above, which can be done in the script anyway. Am I missing something, is there more to it?



    • Edited by sc0r Sunday, August 11, 2013 8:08 PM Update
    Saturday, August 10, 2013 2:04 AM

Answers

  • this is the error

    C:\>winerror 258
       258 WAIT_TIMEOUT <--> No NTSTATUS matched

    printui does not validate the data that you are adding to the registry.

    I'd check the number of printers and drivers as well as the drivers installed on a machine where this is failing.  The spooler may not be fully online and printui does call into spooler for these methods. 

    If you can make an enum printer call before adding the connection information, this may reveal something. 

    My mother told me lurking was not polite.  I'm just attempting to steer people in the path of issue resolution.

     


    Alan Morris Windows Printing Team

    • Marked as answer by Andy Qi Monday, August 19, 2013 1:35 PM
    Monday, August 12, 2013 8:45 PM
    Answerer
  • Sorry for not responding earlier, thanks for responding Alan.

    Spooler service :

    I did several bootlog enabled reboots and looked into procmon. I was initialy suspecting that spooler services was not up when the startup script ran, it looks like services.exe starts spoolsv.exe a full one minute  before start up script kicks in. Is there any way for me to check whether spooler service is ready or not?

    Test env.:

    I have a VM and I startup scripts call the line above to add 5-6 printers. For re-test, I just use /gd to remove any connected printers.

    The whole event is totally inconsistent. Sometime I get all the printers and other times just a few . 

    What is that call doing really? All I see from procmon is that a connection entry is created (if return code is 0). Can I just create these keys and let the spooler take care of connection when the user logs on?

    Update 2013-08-14: This is the solution that worked very well so far: http://www.adilhindistan.com/2013/08/work-around-printuidll-quirkiness-on-xp.html


    • Edited by sc0r Thursday, August 15, 2013 3:02 AM
    • Marked as answer by Andy Qi Monday, August 19, 2013 1:35 PM
    Tuesday, August 13, 2013 2:40 PM

All replies

  • this is the error

    C:\>winerror 258
       258 WAIT_TIMEOUT <--> No NTSTATUS matched

    printui does not validate the data that you are adding to the registry.

    I'd check the number of printers and drivers as well as the drivers installed on a machine where this is failing.  The spooler may not be fully online and printui does call into spooler for these methods. 

    If you can make an enum printer call before adding the connection information, this may reveal something. 

    My mother told me lurking was not polite.  I'm just attempting to steer people in the path of issue resolution.

     


    Alan Morris Windows Printing Team

    • Marked as answer by Andy Qi Monday, August 19, 2013 1:35 PM
    Monday, August 12, 2013 8:45 PM
    Answerer
  • Sorry for not responding earlier, thanks for responding Alan.

    Spooler service :

    I did several bootlog enabled reboots and looked into procmon. I was initialy suspecting that spooler services was not up when the startup script ran, it looks like services.exe starts spoolsv.exe a full one minute  before start up script kicks in. Is there any way for me to check whether spooler service is ready or not?

    Test env.:

    I have a VM and I startup scripts call the line above to add 5-6 printers. For re-test, I just use /gd to remove any connected printers.

    The whole event is totally inconsistent. Sometime I get all the printers and other times just a few . 

    What is that call doing really? All I see from procmon is that a connection entry is created (if return code is 0). Can I just create these keys and let the spooler take care of connection when the user logs on?

    Update 2013-08-14: This is the solution that worked very well so far: http://www.adilhindistan.com/2013/08/work-around-printuidll-quirkiness-on-xp.html


    • Edited by sc0r Thursday, August 15, 2013 3:02 AM
    • Marked as answer by Andy Qi Monday, August 19, 2013 1:35 PM
    Tuesday, August 13, 2013 2:40 PM