Jump to content

Problem with WMI and PrintUI.dll


Recommended Posts

I have a script which uses PrintUI.dll to add a per-machine printer. This script runs as a 'startup script', assigned using Group Policy.

I have another script which uses WMI to enumerate printer connections and set a default based on certain criteria. When I test the script by running it manually, it enumerates all local and network printers, including the per-machine printer added by the first script. When I assign the script as a logon script however, it does not 'see' the per-machine printer, even though it appears once the logon process is complete.

Does anyone know of a good workaround (I can think of a few 'icky' ones)?

Link to comment
Share on other sites


Microsoft's provided tools for printers management really suck to say the least. After messing around for quite a while, I finally made a common VBscript that is called from individual OU scripts. The common script essentially is one huge case select that calls various subroutines. It isn't elegant or pretty, but it works.

The per machine printer has never been reliable for me.

Link to comment
Share on other sites

  • 1 month later...

I'm doing the same thing you're doing - setting per-machine printers in the startup script and setting the default printer in the logon script. I've got it working.

What script are you running to set the default printer? I used the prnmngr.vbs script that is stored in c:\windows\system32 as a reference to create this code to set the per-machine printer as the default printer and it works fine in a logon script. The DefautlPrinter variable is what you would set to the name of your per-machine printer.

DefaultPrinter="\\server\printshare"

const kNameSpace = "root\cimv2"

set oLocator=CreateObject("WbemScripting.SWbemLocator")

set oService=oLocator.ConnectServer("", kNameSpace)

set oPrinter=oService.Get("Win32_Printer.DeviceID='" & DefaultPrinter & "'")

uResult=oPrinter.SetDefaultPrinter

Edited by mlongoh
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...