• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Setting Default Printer via Startup Script

Joined
Dec 7, 2005
Messages
972 (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!
 

OneMoar

There is Always Moar
Joined
Apr 9, 2010
Messages
8,746 (1.70/day)
Location
Rochester area
System Name RPC MK2.5
Processor Ryzen 5800x
Motherboard Gigabyte Aorus Pro V2
Cooling Enermax ETX-T50RGB
Memory CL16 BL2K16G36C16U4RL 3600 1:1 micron e-die
Video Card(s) GIGABYTE RTX 3070 Ti GAMING OC
Storage ADATA SX8200PRO NVME 512GB, Intel 545s 500GBSSD, ADATA SU800 SSD, 3TB Spinner
Display(s) LG Ultra Gear 32 1440p 165hz Dell 1440p 75hz
Case Phanteks P300 /w 300A front panel conversion
Audio Device(s) onboard
Power Supply SeaSonic Focus+ Platinum 750W
Mouse Kone burst Pro
Keyboard EVGA Z15
Software Windows 11 +startisallback
probably need to use make it into a service and have it run delayed start
post the scripts you have tried
 

W1zzard

Administrator
Staff member
Joined
May 14, 2004
Messages
27,049 (3.71/day)
Processor Ryzen 7 5700X
Memory 48 GB
Video Card(s) RTX 4080
Storage 2x HDD RAID 1, 3x M.2 NVMe
Display(s) 30" 2560x1600 + 19" 1280x1024
Software Windows 10 64-bit
Joined
Apr 19, 2012
Messages
12,062 (2.75/day)
Location
Gypsyland, UK
System Name HP Omen 17
Processor i7 7700HQ
Memory 16GB 2400Mhz DDR4
Video Card(s) GTX 1060
Storage Samsung SM961 256GB + HGST 1TB
Display(s) 1080p IPS G-SYNC 75Hz
Audio Device(s) Bang & Olufsen
Power Supply 230W
Mouse Roccat Kone XTD+
Software Win 10 Pro
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

There is Always Moar
Joined
Apr 9, 2010
Messages
8,746 (1.70/day)
Location
Rochester area
System Name RPC MK2.5
Processor Ryzen 5800x
Motherboard Gigabyte Aorus Pro V2
Cooling Enermax ETX-T50RGB
Memory CL16 BL2K16G36C16U4RL 3600 1:1 micron e-die
Video Card(s) GIGABYTE RTX 3070 Ti GAMING OC
Storage ADATA SX8200PRO NVME 512GB, Intel 545s 500GBSSD, ADATA SU800 SSD, 3TB Spinner
Display(s) LG Ultra Gear 32 1440p 165hz Dell 1440p 75hz
Case Phanteks P300 /w 300A front panel conversion
Audio Device(s) onboard
Power Supply SeaSonic Focus+ Platinum 750W
Mouse Kone burst Pro
Keyboard EVGA Z15
Software Windows 11 +startisallback
Joined
Dec 7, 2005
Messages
972 (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 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.
 

OneMoar

There is Always Moar
Joined
Apr 9, 2010
Messages
8,746 (1.70/day)
Location
Rochester area
System Name RPC MK2.5
Processor Ryzen 5800x
Motherboard Gigabyte Aorus Pro V2
Cooling Enermax ETX-T50RGB
Memory CL16 BL2K16G36C16U4RL 3600 1:1 micron e-die
Video Card(s) GIGABYTE RTX 3070 Ti GAMING OC
Storage ADATA SX8200PRO NVME 512GB, Intel 545s 500GBSSD, ADATA SU800 SSD, 3TB Spinner
Display(s) LG Ultra Gear 32 1440p 165hz Dell 1440p 75hz
Case Phanteks P300 /w 300A front panel conversion
Audio Device(s) onboard
Power Supply SeaSonic Focus+ Platinum 750W
Mouse Kone burst Pro
Keyboard EVGA Z15
Software Windows 11 +startisallback
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
 
Joined
Dec 5, 2007
Messages
5,214 (0.87/day)
System Name Addison Clark
Processor Ryzen 9 7950x3D delid
Motherboard Asus X670E Hero
Cooling Custom Bykski loop CPU, GPU, 2x 360 rads, and 1x 280 rad with Arctic P12 and P14 ARGB fans
Memory G.Skill DDR5-6000 64GB CL30
Video Card(s) Gigabyte 4090 Aorus Master
Storage Kingston Fury 2TB and 4TB NVME
Display(s) Samsung 57"
Case Lian Li O11 mini
Audio Device(s) Onboard
Power Supply Thermaltake 1000w SFX-L
Mouse Corsair Dark Core RGB SE
Keyboard Corsair K95 Platnium
Software Win 11 Pro
I use a batch at startup to set the default printer,

@Echo off
RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "Printer Name"
exit
 
Joined
Jul 3, 2008
Messages
174 (0.03/day)
Processor Intel Core i7 5820k
Motherboard MSI X99S-GAMING7
Cooling Corsair H105
Memory 16GB G.SKILL DDR4
Video Card(s) Gigabyte GTX1070 Gaming G1
Storage Samsung 840 Evo 256GB
Display(s) Acer Predator XB271HU
Case Corsair 800D
Audio Device(s) ASUS XONAR
Power Supply Corsair HX850i
Mouse Logitech G502
Keyboard Filco Majestouch
Software Windows 10
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:
Joined
Dec 7, 2005
Messages
972 (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)
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.
 
Joined
Jul 3, 2008
Messages
174 (0.03/day)
Processor Intel Core i7 5820k
Motherboard MSI X99S-GAMING7
Cooling Corsair H105
Memory 16GB G.SKILL DDR4
Video Card(s) Gigabyte GTX1070 Gaming G1
Storage Samsung 840 Evo 256GB
Display(s) Acer Predator XB271HU
Case Corsair 800D
Audio Device(s) ASUS XONAR
Power Supply Corsair HX850i
Mouse Logitech G502
Keyboard Filco Majestouch
Software Windows 10
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

There is Always Moar
Joined
Apr 9, 2010
Messages
8,746 (1.70/day)
Location
Rochester area
System Name RPC MK2.5
Processor Ryzen 5800x
Motherboard Gigabyte Aorus Pro V2
Cooling Enermax ETX-T50RGB
Memory CL16 BL2K16G36C16U4RL 3600 1:1 micron e-die
Video Card(s) GIGABYTE RTX 3070 Ti GAMING OC
Storage ADATA SX8200PRO NVME 512GB, Intel 545s 500GBSSD, ADATA SU800 SSD, 3TB Spinner
Display(s) LG Ultra Gear 32 1440p 165hz Dell 1440p 75hz
Case Phanteks P300 /w 300A front panel conversion
Audio Device(s) onboard
Power Supply SeaSonic Focus+ Platinum 750W
Mouse Kone burst Pro
Keyboard EVGA Z15
Software Windows 11 +startisallback
I think hes just needs to use his orignal script and code a delay so it was :love:0 seconds after login before running
 
Top