Trying to make a printer default on a remote PC using DOS batch file
-
Wednesday, May 16, 2012 3:48 AM
I am trying to install printers remotely using the following DOS command
rundll32 printui.dll PrintUIEntry /ga /n\\print_Server Name\Printer_Name /c\\Computer_name
in the same batch file I am trying to make the installed printer default for all user profiles (XP Pro)
I have been using the follwing DOS command:
rundll32 printui.dll PrintUIEntry /y /n\\print_server_name\Printer_Name /c\\Computer_Name
then using the DOS SC command to stop and start the remote print spooler
can someone please help as the printer is installing but not setting as default printer
- Moved by Mike CrowleyMVP Wednesday, May 16, 2012 4:22 AM (From:Admin)
All Replies
-
Thursday, May 17, 2012 5:56 AMModerator
Hi,
I'd like to confirm what is the OS version?
I'd like to suggest to use Printer Server and Group Policy to achieve the target.
Deploy printers by using Group Policy
http://technet.microsoft.com/en-us/library/cc722179(v=WS.10).aspx
In addition, if there is any windows 2008/vista and later, we can use GPP to deploy the printer:
Printers Extension
http://technet.microsoft.com/en-us/library/cc731562
Hope this helps!
Best regards
Elytis ChengElytis Cheng
TechNet Community Support
- Marked As Answer by Elytis ChengModerator Monday, May 21, 2012 9:52 AM
-
Thursday, May 17, 2012 8:14 PM
Thanks for answering,
The print server is Windows server 2003 SP2, the enviroment is as follows Windows 7 x86, Windows7 x64, Windows XP Pro SP3,
there are 76 printer objects and just under 1000 computers/laptops.
This is a rual WAN Hospital environment in New Zealand
Pieter
- Edited by Pieter Boks Thursday, May 17, 2012 9:52 PM
-
Friday, May 18, 2012 12:00 AMAnswerer
The use of the /ga flag is to add the printer during the next user logon. I think the spooler will also do this on a spooler restart. I suspect the printer is not added until you have restarted the spooler and thus can't set the default. I suggest placing the spooler restart before the setdefault call as well as a sleep for at least 120 seconds. 60 seconds for the spooler to finalize initialization and 60 seconds to download driver and add connection.
I'm assuming the server name difference is a typo in the message.
rundll32 printui.dll PrintUIEntry /ga /n\\print_Server Name\Printer_Name /c\\Computer_name
rundll32 printui.dll PrintUIEntry /y /n\\print_server_name\Printer_Name /c\\Computer_Name
Alan Morris Windows Printing Team
- Marked As Answer by Elytis ChengModerator Monday, May 21, 2012 9:52 AM
-
Friday, May 18, 2012 1:21 AM
In vbscript it could be easy to deal with too.
How to Add a Default Printer Using a Visual Basic Script
or
It would be like that (pasted from above website);
Option Explicit Dim objNetwork, strUNCPrinter strUNCPrinter = "\\LittleServer\HP LaserJet 2420" Set objNetwork = CreateObject("WScript.Network") objNetwork.AddWindowsPrinterConnection strUNCPrinter ' Here is where we set the default printer to strUNCPrinter objNetwork.SetDefaultPrinter strUNCPrinter WScript.Quit
MCP | MCTS 70-236: Exchange Server 2007, Configuring
- Edited by Yagmoth555 Friday, May 18, 2012 1:22 AM
- Marked As Answer by Elytis ChengModerator Monday, May 21, 2012 9:52 AM
-
Sunday, May 20, 2012 8:49 PM
Thanks for the answers Yagmoth555 and Alan, I appreciate the time and effort of both of you, below is the batch file I have come up with.
echo
rundll32 printui.dll printUIEntry /ga /n\\PS1\WICTDBW1
sleep 5
net stop spooler
sleep 5
net start spooler
sleep 5
rundll32 printui.dll printUIEntry /y /n\\PS1\WICTDBW1
sleep 5
net stop spooler
sleep 5
net start spooler
sleep 5
exit
- Edited by Pieter Boks Sunday, May 20, 2012 11:53 PM
- Marked As Answer by Pieter Boks Wednesday, May 23, 2012 11:20 PM
-
Wednesday, May 23, 2012 11:22 PM
Thanks for the help guys, the bachfile is now going through change control.
With thanks
Pieter
- Marked As Answer by Pieter Boks Thursday, May 24, 2012 1:32 AM

