• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Setting Default Printer via Startup Script

Joined
Dec 7, 2005
Messages
975 (0.14/day)
System Name GRAYSCALE\Butterfly
Processor Intel Core i7 8700k @ 5.2Ghz\Intel 4690k
Motherboard ASUS Maximus X Hero \Asus Z97 Maximus Hero VI
Cooling Custom Water\Stock
Memory 2x8GB G.Skill RGB DDR4-3200 \2x8GB Crucial Ballistix DDR3-1600
Video Card(s) NVidia Titan Xp w/ EK Block \ MSI Reference GTX 780
Storage 512GB Samsung 960 PRO (M.2)\128GB OCZ Vertex 4 + 500GB WD Black
Display(s) Asus PG278Q ROG Swift\Acer x213h 21.3'' 1920x1080 LCD
Case Thermaltake P3 Core\NZXT S340
Audio Device(s) Integrated w/ AKG K702 65th Anny's\Integrated
Power Supply Corsair HXi 1000 \Corsair HX850
Mouse Logitech G502 Proteus Spectrum\2014 Razer Naga
Keyboard Ducky One TKL RGB
Software Windows 10 Pro (x64)\Windows 10 Pro (x64)
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!
 
probably need to use make it into a service and have it run delayed start
post the scripts you have tried
 
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)]

Printerscrupt.png
 
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)]

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.
 
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
 
I use a batch at startup to set the default printer,

@Echo off
RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "Printer Name"
exit
 
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
 
Last edited:
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.
 
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.
 
I think hes just needs to use his orignal script and code a delay so it was <30 seconds after login before running
 
Back
Top