Jump to content

Recommended Posts

Posted

Hi folks,

 

I've inherited a domain that uses the CON2PRT routine with a long script and an environment variable to define which PCs connect to what printer (we have a lot of classrooms and printers). Example below:

 

\\dc\NETLOGON\CON2PRT /F (disconnects all printers)

 

IF %Location% == ROOM1 \\dc\NETLOGON\CON2PRT /CD \\prtsrv\room1printer

 

It's an elegant system and until a few weeks ago this was working without issue, but now we're getting up to a third of students with no printers mapping at all. Typically if they switch PCs it works, and they can return to the same PC after switching and then it works.

 

Anyone use this routine and have any idea what could be causing this?

 

The only change to the PCs that I can think of would be Windows Updates. The only workaround I can think of is hard mapping each PC to the printers in the room, and disabling the script.

 

TIA

Posted (edited)

Sorry been years since I used con2prt.. didn't know it was still being used to be honest but you could vbscript it:

 

on error resume next
Set shell= WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
dim Counter, PrinterPath
dim strResult, strLocation

'Remove All Network Printers.
'Commented out because users use mandatory profiles, if this changes add this back in.
Set oPrinters = WshNetwork.EnumPrinterConnections
FOR Counter = 0 To oPrinters.Count - 1
If mid(oPrinters.Item(Counter), 1, 2) = "\\" THEN
	PrinterPath = oPrinters.Item(Counter)
	WshNetwork.RemovePrinterConnection PrinterPath, True, True
End If
Next

'Get the Location and Computer Name from Environment Variables.

strLocation = shell.ExpandEnvironmentStrings("%LOCATION%")


'Add Network Printers based on Location set in Environment Variables

select case strLocation
case "ROOM1"
	addPrinter "\\prtsrv\room1printer",true
	addPrinter "\\prtsrv\room1printer2",false 
	

end select

function addPrinter(strConnectString,isDefault)

	if strConnectString <> "" then
			strResult = WshNetwork.AddWindowsPrinterConnection(strConnectString)
		if isDefault then
			WshNetwork.SetDefaultPrinter strConnectString
		end if
	end if
end function

Edited by apeo
  • Thanks 1
Posted (edited)

Group Policy Preferences if your server OS is up to date enough and can do GPP ?

 

Change the drop down menu from update to create ( as you are creating a new printer as apposed to updating an existing or already added / installed printer that you are pushing out )

 

http://abskb.wordpress.com/2009/07/31/how-to-use-group-policy-preference-to-dynamically-map-printers-when-using-roaming-profiles-2/

 

OR

 

http://www.grouppolicy.biz/2011/01/faq-2-how-do-you-map-printer-using-group-policy-preferences/

 

 

Edited by mac_shinobi
  • Thanks 1

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...