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 arrPrinterGroupsarrGroup = 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?