2007年11月28日 星期三

vb安裝印表機_非分享式的

DIM a
dim strip,strno
dim strprname,strDriverName
dim WshNetwork,strComputer
dim objWMIService,objPrinter
dim strPORTNAME
a = msgbox ("安裝與否",1,"印表機安裝")
'msgbox a
if a = 2 then wscript.quit
'Canon iR2200-3300 PCL6
'***********************************************************************
' print server IP PORT
'***********************************************************************
strip = "192.168.1.100" 'PRINTSERVER IP
strno = ""
strprname = "Canon2200"
strDriverName = "Canon iR2200-3300 PCL6"


'**************************************************************************
' dOS
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
strOS = objOperatingSystem.Caption
Next

'dO_ LPT1
IF strPORTNAME <> "Lpt1:" or strPORTNAME <> "Lpt2:" then
Call insprot
END IF

'**************************************************************************
'Installing a Printer
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objPrinter.DriverName = strDriverName
objPrinter.PortName = strPORTNAME
objPrinter.DeviceID = strprname & "_" & strip
objPrinter.Network = True
objPrinter.Put_

'*******************************************************************************
'wLPORT (insprot)
sub insprot
'Installing Printer Ports
strComputer = "."
strPORTNAME = strprname
Set objWMIService = GetObject("winmgmts:")
Set objNewPort = objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = strPORTNAME
objNewPort.Protocol = 1
objNewPort.Queue = strpid
objNewPort.HostAddress = strip
objNewPort.SNMPEnabled = False
objNewPort.Put_
end sub
'*******************************************************************************
'end
'*******************************************************************************

沒有留言:

RHEL install EPEL

  https://www.linuxtechi.com/install-epel-repo-on-rhel-system/ EPEL dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest...