aku1 发表于 2006-6-5 15:53:16 | 给大家几个注意点:
参考:
'Install printer port Set objWMIService = GetObject("winmgmts:") Set objNewPort = objWMIService.Get _ ("Win32_TCPIPPrinterPort").SpawnInstance_ objNewPort.Name = "IP_10.16.1.232" objNewPort.Protocol = 1 objNewPort.HostAddress = "10.16.1.232" objNewPort.PortNumber = "9100" objNewPort.SNMPEnabled = False objNewPort.Put_
'install printer driver strComputer = "." Set objWMIService = GetObject("winmgmts:" & _ "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objDriver = objWMIService.Get("Win32_PrinterDriver") objDriver.Name = "HP Color LaserJet 5550 PCL 6" objDriver.SupportedPlatform = "Windows NT x86" objDriver.Version = "3" objDriver.FilePath = "\\macs-szmail1\Data\ITEC\Software\Printer\5550dn\english\Drivers\Win32_2000_XP_S2003\PCL6" objDriver.InfName = "\\macs-szmail1\Data\ITEC\Software\Printer\5550dn\english\Drivers\Win32_2000_XP_S2003\PCL6\hpc5550c.inf" intResult = objDriver.AddPrinterDriver(objDriver) WScript.Echo intResult
'Config printer strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_ objPrinter.DriverName = "HP Color LaserJet 5550 " objPrinter.PortName = "IP_10.16.1.232" objPrinter.DeviceID = "HP Color LaserJet 5550 " objPrinter.Location = "SZ" objPrinter.Network = True objPrinter.Shared = False objPrinter.ShareName = " " objPrinter.Put_
很多都参考脚本中心,但死都装不上,总提示如下错误如图:
于是自己思考,已提示显然是不能找到一个类属性,我想很可能,于是定位hpc5550c.inf
最可能是打印机名,于是改成如下:
'Install printer port Set objWMIService = GetObject("winmgmts:") Set objNewPort = objWMIService.Get _ ("Win32_TCPIPPrinterPort").SpawnInstance_ objNewPort.Name = "IP_10.16.1.232" objNewPort.Protocol = 1 objNewPort.HostAddress = "10.16.1.232" objNewPort.PortNumber = "9100" objNewPort.SNMPEnabled = False objNewPort.Put_
'install printer driver strComputer = "." Set objWMIService = GetObject("winmgmts:" & _ "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objDriver = objWMIService.Get("Win32_PrinterDriver") objDriver.Name = "HP Color LaserJet 5550 PCL 6" objDriver.SupportedPlatform = "Windows NT x86" objDriver.Version = "3" objDriver.FilePath = "\\macs-szmail1\Data\ITEC\Software\Printer\5550dn\english\Drivers\Win32_2000_XP_S2003\PCL6" objDriver.InfName = "\\macs-szmail1\Data\ITEC\Software\Printer\5550dn\english\Drivers\Win32_2000_XP_S2003\PCL6\hpc5550c.inf" intResult = objDriver.AddPrinterDriver(objDriver) WScript.Echo intResult
'Config printer strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_ objPrinter.DriverName = "HP Color LaserJet 5550 PCL 6" objPrinter.PortName = "IP_10.16.1.232" objPrinter.DeviceID = "HP Color LaserJet 5550 PCL 6" objPrinter.Location = "SZ" objPrinter.Network = True objPrinter.Shared = False objPrinter.ShareName = " " objPrinter.Put_
|