|
楼上的太不厚到了,好东西不给大家看.
请看我这边的脚本,登陆不同的地方添加不同地方的打印机
在其中我把各地方装有打印机的服务器名字改成server1---5,没办法,不能泄露,万一被别人黑了怎么办,哈哈
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\"& strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each observer5apter in colAdapters
If Not IsNull(observer5apter.IPAddress) Then
For i = 0 To UBound(observer5apter.IPAddress)
if left(observer5apter.IPAddress(i),10)="192.168.0." then loc="MC"
if left(observer5apter.IPAddress(i),10)="192.168.10" then loc="DU"
if left(observer5apter.IPAddress(i),10)="192.168.40" then loc="BA"
if left(observer5apter.IPAddress(i),10)="192.168.50" then loc="LD"
if left(observer5apter.IPAddress(i),10)="192.172.0." then loc="SH"
Next
End If
Next
'WScript.Echo "Location is " & loc
On Error Resume Next
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery ("Select * from Win32_Printer where Network = 1")
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next
dim wshnetwork
if loc = "MC" Then
set wshnetwork=wscript.createobject("wscript.network")
wshnetwork.addwindowsprinterconnection "\\server1\Xerox DC240 Black"
wshnetwork.setdefaultprinter "\\server1\Xerox DC240 Black"
wshnetwork.addwindowsprinterconnection "\\server1\Xerox DC240 Color"
wshnetwork.addwindowsprinterconnection "\\server1\Canon iR3100 Black"
wshnetwork.addwindowsprinterconnection "\\server1\Canon iR3100 Color"
wshnetwork.addwindowsprinterconnection "\\server1\HPLJ2600B"
wshnetwork.addwindowsprinterconnection "\\server1\HPLJ2600C"
end If
if loc = "DU" Then
set wshnetwork=wscript.createobject("wscript.network")
wshnetwork.addwindowsprinterconnection "\\server2\XeroxPro35"
wshnetwork.setdefaultprinter "\\server2\XeroxPro35"
wshnetwork.addwindowsprinterconnection "\\server2\XeroxPhaser"
end If
if loc = "BA" Then
set wshnetwork=wscript.createobject("wscript.network")
wshnetwork.addwindowsprinterconnection "\\server3\Canon2200B"
wshnetwork.setdefaultprinter "\\server3\Canon2200B"
wshnetwork.addwindowsprinterconnection "\\server3\Canon2200F"
end If
if loc = "LD" Then
set wshnetwork=wscript.createobject("wscript.network")
wshnetwork.addwindowsprinterconnection "\\server4\XeroxPro45"
wshnetwork.setdefaultprinter "\\server4\XeroxPro45"
end If
if loc = "SH" Then
set wshnetwork=wscript.createobject("wscript.network")
wshnetwork.addwindowsprinterconnection "\\server5\xerox"
wshnetwork.setdefaultprinter "\\server5\xerox"
wshnetwork.addwindowsprinterconnection "\\server5\ricoh"
wshnetwork.addwindowsprinterconnection "\\server5\kyocera"
end If |
|