Option Explicit
Dim WSHNetwork, Computer, Path, strComputerDN, objSysInfo, objComputer, sPrintPath, PrintLocation
Dim objWMIService, colInstalledPrinters, objPrinter
Set WSHNetwork = CreateObject("WScript.Network")
On Error Resume Next
Path = WSHNetwork.ComputerName
Set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = objSysInfo.ComputerName
Set objComputer = GetObject("LDAP://" & strComputerDN)
Select Case objComputer.Get("Location")
Case "first"
sPrintPath = "\\10.0.0.201\HP1320"
sPrintPath1 = "\\10.0.0.201\HP3390"
PrintLocation = "HP1320 First"
Case "second"
sPrintPath = "\\10.0.0.201\HP3390"
sPrintPath1 = "\\10.0.0.201\HP1320"
PrintLocation = "HP3390 Second"
Case Else
MsgBox("Обратитесь к администратору") :WScript.Quit
End Select
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
If PrintLocation = objPrinter.Location Then
WScript.Quit
End If
Next
WSHNetwork.AddWindowsPrinterConnection sPrintPath
WSHNetwork.AddWindowsPrinterConnection sPrintPath1
WSHNetwork.SetDefaultPrinter sPrintPath