Set Default Printer
I needed to find a way to set the default printer via a Deployment Console job. I have found a few different ways of doing it.
The first is a vbs script:
Set WSHNetwork = CreateObject("WScript.Network")
WSHNetwork.SetDefaultPrinter "[PRINTER_NAME]"
For more info check out this web site: http://www.intelliadmin.com/blog/2007/08/set-defau...
The second can be used in the command prompt:
start /W RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "[Printer_Name]"
For more information check out this web site: http://www.robvanderwoude.com/2kprintcontrol.php
You can even enter in the server location for a printer, it needs to be in this format: \\Path\Printer_Name
This script works well and most importantly it does the job.
Set Default Printer
I have done something similar. I use the script below in GPO.
GPO -> User Configuration -> Windows Settings -> Scripts (Logon/Logoff) -> Logon.
In the "Add a Script" dialog, type DefaulPrinter.vbs in "Script Name" and type \\server\printer in "Script Parameters".
Multiple users
I believe the default printer setting is user-specific, so keep that in mind if multiple users use the machine.
I have my default printer
I have my default printer name stored in a registry key. Is there a way to create a VBS script that will query the key, set the keys value as a variable, and stick that variable into the script above?
I have done it with a BAT file:
:: delims is a TAB followed by a space
FOR /F "tokens=3 delims= " %%A IN ('REG QUERY "HKLM\Software\Path\To\Key" /v DefaultPrinterName') DO SET DefaultPrinterName=%%A
ECHO Name=%DefaultPrinterName%
ECHO Installing the Printer (%DefaultPrinterName%)...
start /W RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "%DefaultPrinterName%"
Any ideas on how to do it with a VBS script?
Query Registry using vbs
This vbs does the same thing as your bat. You need to make som changes in the script if the registry key is not located in HKEY_LOCAL_MACHINE and the value is not a string value.
The Hey, Scripting Guy! Archive have been very useful for me. It makes learning vbs so much easier.
Would you like to reply?
Login or Register to post your comment.