Hi my environment is
Server: Windows 2012 r2
Clients: Windows 10 Professional
I have a vbs script that works fine with Windows 7 in deploying printers based on OU. I have tried to apply the same script to Windows 10 however this does not work. Can someone please tell me what I need to do to get this working.
my script is as follows:
Error Resume Next'
set objSysInfo = CreateObject("ADSystemInfo")
strName = objSysInfo.ComputerName
arrComputerName = Split(strName, ",")
arrOU = Split(arrComputerName(1), "=")
strComputerOU = arrOU(1)
Set objNetwork = CreateObject("WScript.Network")
arrpc = Split(arrComputerName(0), "=")
strComputerName = arrpc(1)
REM ***Remove Network Printers***
Set wshNet = CreateObject("WScript.Network")
Set wshPrn = wshNet.EnumPrinterConnections
For x = 0 To wshPrn.Count - 1 Step 2
If Left(wshPrn.Item(x+1),2) = "\\" Then wshNet.RemovePrinterConnection wshPrn.Item(x+1),True,True
Next
Select Case strComputerOU
Case "staffroom"
ObjNetwork.AddWindowsPrinterConnection "\\AW-FP01\Admin Photocopier"
ObjNetwork.AddWindowsPrinterConnection "\\AW-FP01\Admin Kyocera Printer"
ObjNetwork.SetDefaultPrinter "\\AW-FP01\Main Admin Kyocera Printer"
end select
WScript.Quit
The removing of the printers works fine. the ObjNetwork.AddWindowsPrinterConnection and the ObjNetwork.SetDefaultPrinter work if they are applied in a separate .vbs file. The problem appears to be determining the OU, and then mapping a printer according to the OU.
Like I say, the code itself is fine, because it works on Windows 7. It appears to be an issue with Windows 10. I'm hoping there's someone out there that knows the work around for this. I need to somehow find a solution for this.