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.
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
'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
if strConnectString <> "" then
strResult = WshNetwork.AddWindowsPrinterConnection(strConnectString)
if isDefault then
My head certainly hurts now :) I'll give it a go though, when the opportunity presents itself.
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 )
Would this work where the student location changes all the time? i.e. they only get printers relevant for the room they're in.