Automating Replacing Printer drivers

Hi,

Has anyone here have experience with the following ?
I’m currently looking for a solution for replacing ± 800 printer drivers on ± 18000 end points where the old printer driver needs to be removed and the new added depending on which printer it was that is being removed, and which takes into account which user was using it.

So far I’ve made the following action script for adding the new printer driver (since the drivers are already on the server and will be installed when being accessed):
waithidden c:\Apps\IBM\RunAsCurrentUser.exe cmd.exe /C explorer.exe \servername\printername

However it will be a huge script if i have to match 800 old printers with the new printers in action script lines like this. And i suspect i will create a decent load on the network and/or clients when the clients have to check if the 800 printers are available.

Does anyone have a suggestion for improvement ?

@raphaelwahl so he can track this topic aswel :wink:

1 Like

We deal with our contracted copiers that roll-in and out on a four year cycle this way. You should be able to sort through what we do. We use the prnmgr.vbs script that has been included on every Windows operating system I know of to do the heavy lifting.
First we capture who is using a given printer (there are around 8 in our corporate office). This relevance when applied to a BigFix group helps us capture who has a specific printer installed.
exists values “\cle-print\HR Copier-Printer 4555c” of keys “Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts” of current user keys (logged on users) of registry

We also capture who has a given printer as their default printer with this:
exists (value “Device” of keys “Software\Microsoft\Windows NT\CurrentVersion\Windows” of keys (component string of sid of security account (name of current user)) of keys “HKEY_USERS” of registry) whose (it as string as lowercase contains “\cle-print\HR Copier-Printer 4555c” as lowercase)
We create a group for every printer in the office that is hosted by the print server.

Then we use the following relevance
((exists true whose (if true then (/* HR Copier-Printer 4555c is installed / exists (value “\cle-print\HR Copier-Printer 4555c” of keys “Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts” of keys (component string of sid of security account (name of current user)) of keys “HKEY_USERS” of registry)) else false)) AND (exists true whose (if true then (/ BigFix RunAsCurrentUser exe is in place / if (x64 of operating system) then (exists file “C:\Program Files (x86)\BigFix\RunAsCurrentUser\RunAsCurrentUser.exe”) else (if (x32 of operating system) then (exists file “C:\Program Files\BigFix\RunAsCurrentUser\RunAsCurrentUser.exe”) else false)) else false)) AND (exists true whose (if true then (/ Printer Admin Script is present / exists file “C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs”) else false)) AND (exists true whose (if true then (/ A user is logged on; required for RunAsCurrentUser */ exists current user) else false)))
To run the following task that; installs the new shared printer, sets the default printer and deletes the old printer: (we keep the RunAsCurrentUser.exe local)
//Modify this template by running a find and replace on CLE.HR.Toshiba4555c

//Install the new printer
if {x64 of operating system}
waithidden “C:\Program Files (x86)\BigFix\RunAsCurrentUser\RunAsCurrentUser.exe” --w --q cscript “C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs” -ac -p "\cle-print\CLE.HR.Toshiba4555c"
else
waithidden “C:\Program Files\BigFix\RunAsCurrentUser\RunAsCurrentUser.exe” --w --q cscript “C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs” -ac -p "\cle-print\CLE.HR.Toshiba4555c"
endif

//If the old printer is set as the default, set the new printer as the default
if {exists (value “Device” of keys “Software\Microsoft\Windows NT\CurrentVersion\Windows” of keys (component string of sid of security account (name of current user)) of keys “HKEY_USERS” of registry) whose (it as string as lowercase contains “\cle-print\HR Copier-Printer 4555c” as lowercase)}
if {x64 of operating system}
waithidden “C:\Program Files (x86)\BigFix\RunAsCurrentUser\RunAsCurrentUser.exe” --w --q cscript “C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs” -t -p "\cle-print\CLE.HR.Toshiba4555c"
else
waithidden “C:\Program Files\BigFix\RunAsCurrentUser\RunAsCurrentUser.exe” --w --q cscript “C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs” -t -p "\cle-print\CLE.HR.Toshiba4555c"
endif
endif

//Uninstall the old printer
if {x64 of operating system}
waithidden “C:\Program Files (x86)\BigFix\RunAsCurrentUser\RunAsCurrentUser.exe” --w --q cscript “C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs” -d -p "\cle-print\HR Copier-Printer 4555c"
else
waithidden “C:\Program Files\BigFix\RunAsCurrentUser\RunAsCurrentUser.exe” --w --q cscript “C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs” -d -p "\cle-print\HR Copier-Printer 4555c"
endif

If you have 800 shared printers on the network, I would create each of these three examples making them pertain to your environment then do an export of each one to get an .XML to use as a template of what needs done. Then I would write a script that would create a huge .BES (.xml) file programmatically from your list of 800 printers appending the template for each printer then import it into BigFix.

1 Like

I forgot to mention the BF Groups help show what needs done, then as it is running you can see whats hasn’t finished as the group members vanish.

Thanks for the feedback.

I’ve been trying to use the template for the default printer, however with my tests i don’t get the desired result.
My default printer doesn’t get changed, but the fixlet reports as completed.

What is weird is that when i try this in cmd with the runascurrentuser.exe application it works.
When i run it in the fixletdebugger or through BigFix i get a positive result but i don’t see the change in the registry.

Sounds like you are not getting runascurrentuser.exe to work. We place the runascurrentuser.exe on the computer and call it by path that seems to make things work better for us.

The positive result on the task is probably due to not setting “custom success criteria” of the task to use “the applicability relevance evaluates to false”

I couldn’t get it to work in the fixlet debugger but it does work when put in a task.
It works for me with the following lines:

// if old printer -> install new printer
if {exists (value “\old_printer” of keys “Software\Microsoft\Windows NT\CurrentVersion\Devices” of keys (component string of sid of security account (name of current user)) of keys “HKEY_USERS” of registry)}
waithidden c:\Apps\IBM\RunAsCurrentUser.exe cmd.exe /C explorer.exe \new_printer

//if old printer = default printer
//set new printer = default printer

if {exists (value “Device” of keys “Software\Microsoft\Windows NT\CurrentVersion\Windows” of keys (component string of sid of security account (name of current user)) of keys “HKEY_USERS” of registry) whose (it as string as lowercase contains “\old_printer” as lowercase)}
waithidden c:\Apps\IBM\RunAsCurrentUser.exe --q cmd.exe /C cscript c:\windows\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs -t -p \new_printer
endif

// and delete old printer

waithidden c:\Apps\IBM\RunAsCurrentUser.exe --q cmd.exe /C cscript c:\windows\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs -d -p \old_printer
endif

the reason i’m assuming it doesn’t work with my fixlet debugger was because it runs on elevated rights and it tries to add the printer on that profile instead of the current (normal) user.
In the end it works with these lines, now only the multiplying part rests to be solved.