Jump to content

Recommended Posts

Posted

Hi everyone,

 

We currently have our default printer set by Group Policy but a member of staff needs a different default printer for certain reasons. Is there a way to have a start-up script change the default printer or is there another option?

 

The current default printer would be \\printserver1\printer1 and the new default needs to be \\printserver2\printer2

 

I have looked on a few sites but I've not been able to get anything to work. We are currently using windows 8.1 but will be moving to windows 10 in the future (6 months). I'm hoping that this is quite a simple task as I have no experience with PowerShell scripts so don't really know where to start.

 

Any help is greatly appreciated

 

Noel

Posted (edited)

You can do it via 'Item level targeting', under the 'common' tag, in group policy preferences.

 

This will let you set up specific rules for individual groups or users in AD.

Edited by TriggerHappyUK
Posted

Hi,

 

Thanks for the reply. I should have said i don't have access to edit our group policy so that isn't an option.

 

Thanks

 

Noel

Posted (edited)
Try adprintx.exe. a command that allows you to add printers via script. Using cd switch will create as a default printer. You can include these script in group policy. Group policy would be a lot easier and recommend getting access but as you don't have access this is probably the next best thing Edited by dapaulio
Posted

Hi,

 

Thanks for the ideas and advice. I was able to get this working using the following script and set the batch file to run at start-up for the user.

 

rundll32 printui.dll,PrintUIEntry /n \\server2\Printer2 /y

 

Thanks

 

Noel

  • 6 months later...
Posted

this is a script i wrote for out printers.

our PC's are SDTRRRNN (RRR is room and NN is pc number)

our printers are SPTRRRNN (RRR is room and NN is printer number)

 

this VBS script at user login, looks for printers in the same room as the machine and sets them as default.

It then has a manual override for them strange non standard sections.

 

might not be any help to anyone but here it is.

 

' TICKET 11609
' Created By X - 17/05/2013


'#################################
BlacklistArray = Array("CutePDF Writer","Adobe PDF","Microsoft XPS Document Writer","SagePDFPrinter","WebEx Document Loader","Fax","Microsoft Print to PDF","Send To OneNote 16")

'On Error Resume Next
'#################################
'######   DO NOT EDIT START  #####
'#################################
'GET LOCAL COMPUTER NAME
Set wshNetwork = WScript.CreateObject( "WScript.Network" )
strCompCode = ucase(left(wshNetwork.ComputerName,1)) & ucase(right(left(wshNetwork.ComputerName,6),3))

IF ucase(left(wshNetwork.ComputerName,3))="SDT" OR ucase(left(wshNetwork.ComputerName,3))="STB" OR ucase(left(wshNetwork.ComputerName,3))="JDT" OR ucase(left(wshNetwork.ComputerName,3))="JTB" THEN 
WScript.Sleep(20000)
		
	'CHECK FOR PRINTERS WITH SAME NAME AS PC ON THE NETWORK
	Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
	Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
	For Each objPrinter in colPrinters
		IF not objPrinter.Attributes And 64 Then 
			'NETWORK ON LOCAL
			PrinterArray = split(objPrinter.Name,"\")
			PrinterName1 = ucase(PrinterArray(3))
			PrinterCode1 = ucase(left(PrinterName1,1)) & ucase(right(left(PrinterName1,6),3))
			IF PrinterCode1 = strCompCode THEN WshNetwork.SetDefaultPrinter objPrinter.Name
			TestingEcho1 = TestingEcho1 & strCompCode1 & " PRINTERCODE=(" & PrinterCode1 & ") - (" & ucase(PrinterArray(2)) & "\" & PrinterName1 & ") " & vbCrLf
			IF PrinterCode1 = strCompCode THEN TestingEcho1B = TestingEcho1B & objPrinter.Name & vbCrLf
		End IF
	Next
			
	'CHECK FOR LOCAL PRINTERS, SKIP ANY LISTED	
	Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
	Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
			For Each objPrinter in colPrinters
				BlacklistDevice = 0
					IF objPrinter.Attributes And 64 Then
						'LOCAL PRINTERS ON LOCAL
						For each x in BlacklistArray
							IF x = objPrinter.Name Then BlacklistDevice = 1	
						Next
								IF BlacklistDevice = 0 then
									WshNetwork.SetDefaultPrinter objPrinter.Name
								ELSE
									EchoSkipped = " - ( Blacklisted in script )"
								End IF
					TestingEcho2 = TestingEcho2 & "PRINTER NAME=(" & objPrinter.Name & ")" & EchoSkipped & vbCrLf
					EchoSkipped = NULL
					End IF
			Next	
ELSE
DebugMSGFail = "##################################" & vbCrLf & "FAIL: Automatic selection not enabled for this PC name" & vbCrLf & "##################################" & vbCrLf & vbCrLf
'WScript.quit
End IF







'WScript.Sleep(10000)

'#################################
'######  DO NOT EDIT FINISH  #####
'#################################


'MANUAL MAPPINGS
'######################################################################################################################
IF wshNetwork.ComputerName = "SDT253080000" THEN WshNetwork.SetDefaultPrinter "\\theia\SPT254015350" 'Temp PE

'######################################################################################################################


'//#################################
'//#################################
'//#######   DEBUG SECTION   #######
'//#################################
'//#################################
	Set WshShell = CreateObject("WScript.Shell") 
	defaultprn = WshShell.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device")
	arrPrnStr = Split(defaultprn,",")
	fullPrinterString = arrPrnStr(0)
	arrFullPrnStr = Split(fullPrinterString,"\")
	shortPrinterName= arrFullPrnStr(Ubound(arrFullPrnStr))
'//################
	IF TestingEcho1B = "" then TestingEcho1B = "No network printers match" & vbCrLf & vbCrLf
	DebugMSG1 = "THIS PC CODE" & vbCrLf & "===============" & vbCrLf & "PCCODE=(" & strCompCode &  ") - (" & wshNetwork.ComputerName & ")" & vbCrLf & vbCrLf & vbCrLf 
	DebugMSG2 = "NETWORK PRINTERS" & vbCrLf & "===============" & vbCrLf & TestingEcho1 & vbCrLf & "Match list:" & vbCrLf & TestingEcho1B & vbCrLf & vbCrLf
	DebugMSG3 = "LOCAL PRINTERS" & vbCrLf & "===============" & vbCrLf & TestingEcho2 & vbCrLf & vbCrLf
	DebugMSG4 = "DEFAULT PRINTER" & vbCrLf & "==============================" & vbCrLf & "Your default printer is set to " & shortPrinterName
'//#################################
'//#################################
'//#################################
'/### ENABLE BELOW FOR REPORTS
	Wscript.Echo DebugMSGFail & DebugMSG1 & DebugMSG2 & DebugMSG3 & DebugMSG4
	Wscript.Echo "Done"

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...