# Setting Default Printer via Startup Script



## Wastedslayer (Jun 10, 2015)

I'm ready to admit defeat on this one. I recently took over a school network and have been working to migrate them away from a 3rd party application known as Desktop Authority. It's basically an alternative to Group Policy from what I have gathered.

Part of this process involves re-configuring the way that our Printers are deployed, and which one is the default. Here is where it gets tricky, I can't select a printer for a USER, I need the printer to be set for the COMPUTER (Kids and teachers move around). Simple enough, configure Deployed Printers in the GPO and go on our merry way. The problem comes when a teacher, or a classroom needs to have their default printer changed. These machines are "Frozen" with Faronics DeepFreeze and so any changes made would revert upon a restart. Sure, we could go to each machine and re-configure the default printer... but with 3200 computers that will take some time.

Ideally I would like to use a STARTUP script to map the default printer. However, I've tried just about everything on the web with no success. VB Scripts, BAT Files, etc. WMIC Printer Where name... Rundll32... and nothing. The default printer stays the same. I've verified the scripts are running, and when run manually they work fine. I feel like during the boot process it's to soon to select the printer. Permissions and everything are fine as well.

Either way, I'm hoping that someone has some experience with something similar or at least a type of workaround.

Thanks for any help!


----------



## OneMoar (Jun 11, 2015)

probably need to use make it into a service and have it run delayed start
post the scripts you have tried


----------



## W1zzard (Jun 11, 2015)

https://technet.microsoft.com/en-us/library/ee624057.aspx

/c command line parameter looks interesting for remote

You might have to restart the print spooler service (sc stop spooler ; start start spooler)


----------



## RCoon (Jun 11, 2015)

I do it with VB logon scripts


"Dim ps0 *[<------ our printer server the printers are added/managed on]*
Dim printer

ps0 = "\\ps0\"
printer = "S14 - Oki ES4140" *[<------- the name of the printer as it is shown on the server]*

Set wshNetwork = CreateObject("WScript.Network")
on Error Resume Next

'Deletes all network printers
Set clPrinters = wshNetwork.EnumPrinterConnections
On Error Resume Next
For i = 0 to clPrinters.Count - 1 Step 2
wshNetwork.RemovePrinterConnection clPrinters.Item(i+1), true
Next

'Add Network printer
wshNetwork.AddWindowsPrinterConnection ps0 & printer

'Set Default Printer
wshNetwork.SetDefaultPrinter ps0 & printer" *[<------ this bit sets it as default (note: this must be applied as the first policy before any other printers policies, otherwise it deletes them)]*


----------



## OneMoar (Jun 11, 2015)

W1zzard said:


> https://technet.microsoft.com/en-us/library/ee624057.aspx
> 
> /c command line parameter looks interesting for remote
> 
> You might have to restart the print spooler service (sc stop spooler ; start start spooler)


pretty much beat me to it >)


----------



## Wastedslayer (Jun 11, 2015)

RCoon said:


> I do it with VB logon scripts
> 
> 
> "Dim ps0 *[<------ our printer server the printers are added/managed on]*
> ...



This looks like a good solution, and similar to some of the VB scripts I tried.. but it is a logon script. I would need something that works as a startup script. We are not mapping printers to users as they move around too much, but rather mapping to each computer.

The Link that W1ZZARD posted is good information. Sadly however, I have tried utilizing most of the commands that are available. The /c command is indeed interesting, but we are trying to map them when a computer starts up (prior to logon screen) versus just mapping them remotely. The purpose would be if we had a lab that needed the default printer changed, sure we could just send the remote command to each machine, or even remote into them ourselves and manually do it, but I was looking for a smoother alternative.

It seems like its just something that will have to be done manually and with user education.

Thanks for all the suggestions though.


----------



## OneMoar (Jun 11, 2015)

if the login script isn't working you may need to use task scheduler and invoke wscript as admin  I would also change the script so it invokes "sc stop spooler" before executing then then invokes " sc start spooler" after changing the printer


----------



## kenkickr (Jun 11, 2015)

I use a batch at startup to set the default printer,  

@Echo off
RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "Printer Name"
exit


----------



## Rhyseh (Jun 12, 2015)

If the Domain Function level is 2008 why not simply use User Group Policy Preferences? You could then setup Item Level Targeting or location based GPO's to set different defaults depending on location. You could also place all the machines into a specific OU, configure Group Policy Loop Back processing and assign the GPO to the machine OU. This is generally how you configure group policy for terminal servers...

Using GPP to deploy printers:
http://blogs.technet.com/b/grouppolicy/archive/2009/06/24/gp-preferences-set-a-default-printer.aspx

Group Policy Loopback Processing:
https://support.microsoft.com/en-us/kb/231287

Item Level Targetting:
https://msdn.microsoft.com/en-us/library/cc733022.aspx

Here's a nice spiceworks article that outlines the process in more granular detail. It's probably not exactly how I would do it, but it should work just as well as any deployment method:
http://community.spiceworks.com/how_to/292-set-the-default-printer-via-group-policy


----------



## Wastedslayer (Jun 18, 2015)

Rhyseh said:


> If the Domain Function level is 2008 why not simply use User Group Policy Preferences? You could then setup Item Level Targeting or location based GPO's to set different defaults depending on location. You could also place all the machines into a specific OU, configure Group Policy Loop Back processing and assign the GPO to the machine OU. This is generally how you configure group policy for terminal servers...



GPP have always been hit or miss in my experience, especially with printers. Though I did screw around with them in an attempt at getting this to work. Not much luck though. Perhaps I'll revisit the idea.

Kenkickr, I'll give that script a try, but I was testing with something similar and it seemed like my success was 50/50

Thanks for all the help everyone.


----------



## Rhyseh (Jun 19, 2015)

Wastedslayer said:


> GPP have always been hit or miss in my experience, especially with printers. Though I did screw around with them in an attempt at getting this to work. Not much luck though. Perhaps I'll revisit the idea.
> 
> Kenkickr, I'll give that script a try, but I was testing with something similar and it seemed like my success was 50/50
> 
> Thanks for all the help everyone.



If you are working with 2008 R2+ DC's and Win 7+ clients GPP is normally pretty reliable. You just need to make sure that it is applying/configured correctly. I've setup a few sites with 200+ seats with a multitude of printer policies being set by GPP and it works flawlessly. Having said this I have seen some strange interactions with terminal servers and printers set via GPP.


----------



## OneMoar (Jun 19, 2015)

I think hes just needs to use his orignal script and code a delay so it was 0 seconds after login before running


----------

