Prev: HTA Application problem - mshta.exe will not terminate
Next: Does WMI Provide NIC Speed/Duplex Info Somewhere?
From: Brian on 24 Feb 2005 17:51 I have 6 NT servers with about 300 printers each on them. I need to migrate these printers to a 2003 box. I have a couple of scripts from Script Center that add a printer, add a port, list port properties and list printer capabilities. The only problem is that NT only supports the List printer capabilitites. Does anyone know of a way that I can pull the necessary port and printer information from my NT servers so that I can add them back to my 2003 server via script. Here are the sample scripts I'm starting from: List Printer Capabilities: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * from Win32_PrinterConfiguration") For Each objPrinter in colInstalledPrinters Wscript.Echo "Name: " & objPrinter.Name Wscript.Echo "Collate: " & objPrinter.Collate Wscript.Echo "Copies: " & objPrinter.Copies Wscript.Echo "Driver Version: " & objPrinter.DriverVersion Wscript.Echo "Duplex: " & objPrinter.Duplex Wscript.Echo "Horizontal Resolution: " & _ objPrinter.HorizontalResolution If objPrinter.Orientation = 1 Then strOrientation = "Portrait" Else strOrientation = "Landscape" End If Wscript.Echo "Orientation : " & strOrientation Wscript.Echo "Paper Length: " & objPrinter.PaperLength / 254 Wscript.Echo "Paper Width: " & objPrinter.PaperWidth / 254 Wscript.Echo "Print Quality: " & objPrinter.PrintQuality Wscript.Echo "Scale: " & objPrinter.Scale Wscript.Echo "Specification Version: " & _ objPrinter.SpecificationVersion If objPrinter.TTOption = 1 Then strTTOption = "Print TrueType fonts as graphics." Elseif objPrinter.TTOption = 2 Then strTTOption = "Download TrueType fonts as soft fonts." Else strTTOption = "Substitute device fonts for TrueType fonts." End If Wscript.Echo "True Type Option: " & strTTOption Wscript.Echo "Vertical Resolution: " & objPrinter.VerticalResolution Next ******************************************************* List Port Properties strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colPorts = objWMIService.ExecQuery _ ("Select * from Win32_TCPIPPrinterPort") For Each objPort in colPorts Wscript.Echo "Description: " & objPort.Description Wscript.Echo "Host Address: " & objPort.HostAddress Wscript.Echo "Name: " & objPort.Name Wscript.Echo "Port Number: " & objPort.PortNumber Wscript.Echo "Protocol: " & objPort.Protocol Wscript.Echo "SNMP Community: " & objPort.SNMPCommunity Wscript.Echo "SNMP Dev Index: " & objPort.SnMPDevIndex Wscript.Echo "SNMP Enabled: " & objPort.SNMPEnabled Next ****************************************************** Install a Printer: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_ objPrinter.DriverName = "HP LaserJet 4000 Series PS" objPrinter.PortName = "IP_169.254.110.160" objPrinter.DeviceID = "ScriptedPrinter" objPrinter.Location = "USA/Redmond/Building 37/Room 114" objPrinter.Network = True objPrinter.Shared = True objPrinter.ShareName = "ScriptedPrinter" objPrinter.Put_ ***************************************************** Install a Printer Port: Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objNewPort = objWMIService.Get _ ("Win32_TCPIPPrinterPort").SpawnInstance_ objNewPort.Name = "IP_169.254.110.14" objNewPort.Protocol = 1 objNewPort.HostAddress = "169.254.110.14" objNewPort.PortNumber = "9999" objNewPort.SNMPEnabled = False objNewPort.Put_ -- Thanks for the help! Brian
From: Steve Seguis [MVP] on 24 Feb 2005 20:00 Have you looked at the printmig.exe tool from the Windows Resource Kit? -- Steve Seguis - MCSE, MVP Windows Server, SCJP SCRIPTMATION, INC. Automating the Enterprise http://www.scriptmation.com "Brian" <Brian(a)discussions.microsoft.com> wrote in message news:E74AA925-04EA-45E4-8A5D-00D4BEA9573F(a)microsoft.com... >I have 6 NT servers with about 300 printers each on them. I need to >migrate > these printers to a 2003 box. I have a couple of scripts from Script > Center > that add a printer, add a port, list port properties and list printer > capabilities. The only problem is that NT only supports the List printer > capabilitites. Does anyone know of a way that I can pull the necessary > port > and printer information from my NT servers so that I can add them back to > my > 2003 server via script. > > Here are the sample scripts I'm starting from: > > List Printer Capabilities: > > strComputer = "." > Set objWMIService = GetObject("winmgmts:" _ > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > > Set colInstalledPrinters = objWMIService.ExecQuery _ > ("Select * from Win32_PrinterConfiguration") > > For Each objPrinter in colInstalledPrinters > Wscript.Echo "Name: " & objPrinter.Name > Wscript.Echo "Collate: " & objPrinter.Collate > Wscript.Echo "Copies: " & objPrinter.Copies > Wscript.Echo "Driver Version: " & objPrinter.DriverVersion > Wscript.Echo "Duplex: " & objPrinter.Duplex > Wscript.Echo "Horizontal Resolution: " & _ > objPrinter.HorizontalResolution > If objPrinter.Orientation = 1 Then > strOrientation = "Portrait" > Else > strOrientation = "Landscape" > End If > Wscript.Echo "Orientation : " & strOrientation > Wscript.Echo "Paper Length: " & objPrinter.PaperLength / 254 > Wscript.Echo "Paper Width: " & objPrinter.PaperWidth / 254 > Wscript.Echo "Print Quality: " & objPrinter.PrintQuality > Wscript.Echo "Scale: " & objPrinter.Scale > Wscript.Echo "Specification Version: " & _ > objPrinter.SpecificationVersion > If objPrinter.TTOption = 1 Then > strTTOption = "Print TrueType fonts as graphics." > Elseif objPrinter.TTOption = 2 Then > strTTOption = "Download TrueType fonts as soft fonts." > Else > strTTOption = "Substitute device fonts for TrueType fonts." > End If > Wscript.Echo "True Type Option: " & strTTOption > Wscript.Echo "Vertical Resolution: " & objPrinter.VerticalResolution > Next > > ******************************************************* > > List Port Properties > > strComputer = "." > Set objWMIService = GetObject("winmgmts:" _ > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > > Set colPorts = objWMIService.ExecQuery _ > ("Select * from Win32_TCPIPPrinterPort") > > For Each objPort in colPorts > Wscript.Echo "Description: " & objPort.Description > Wscript.Echo "Host Address: " & objPort.HostAddress > Wscript.Echo "Name: " & objPort.Name > Wscript.Echo "Port Number: " & objPort.PortNumber > Wscript.Echo "Protocol: " & objPort.Protocol > Wscript.Echo "SNMP Community: " & objPort.SNMPCommunity > Wscript.Echo "SNMP Dev Index: " & objPort.SnMPDevIndex > Wscript.Echo "SNMP Enabled: " & objPort.SNMPEnabled > Next > ****************************************************** > Install a Printer: > > strComputer = "." > Set objWMIService = GetObject("winmgmts:" _ > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > > Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_ > > objPrinter.DriverName = "HP LaserJet 4000 Series PS" > objPrinter.PortName = "IP_169.254.110.160" > objPrinter.DeviceID = "ScriptedPrinter" > objPrinter.Location = "USA/Redmond/Building 37/Room 114" > objPrinter.Network = True > objPrinter.Shared = True > objPrinter.ShareName = "ScriptedPrinter" > objPrinter.Put_ > > ***************************************************** > Install a Printer Port: > > Set objWMIService = GetObject("winmgmts:" _ > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > Set objNewPort = objWMIService.Get _ > ("Win32_TCPIPPrinterPort").SpawnInstance_ > > objNewPort.Name = "IP_169.254.110.14" > objNewPort.Protocol = 1 > objNewPort.HostAddress = "169.254.110.14" > objNewPort.PortNumber = "9999" > objNewPort.SNMPEnabled = False > objNewPort.Put_ > > > -- > Thanks for the help! > Brian
From: Brian on 25 Feb 2005 09:39 Yes we use it quite often. Here's the deal. A couple of years ago we realized that when we installed let's say 200 printers we maxed out the registery and the server would crash. Microsoft gave us a patch that split the printer section into two parts and allowed for a bigger registery so we could install 300 printers. Now when we run the printmig tool it get all freaked out and doesn't understand how the printers are split. So I really just need some way to get the Port Name and IP address and then the Print Driver name, Printer name, Printer location, and share name. Also I'm at a loss as to why the only sample script supported by NT is the List Printer Capabilities. Can I install some sort of extensions or something on my NT servers so I can run the other sample scripts against them? "Steve Seguis [MVP]" wrote: > Have you looked at the printmig.exe tool from the Windows Resource Kit? > > -- > Steve Seguis - MCSE, MVP Windows Server, SCJP > SCRIPTMATION, INC. > Automating the Enterprise > http://www.scriptmation.com > > > "Brian" <Brian(a)discussions.microsoft.com> wrote in message > news:E74AA925-04EA-45E4-8A5D-00D4BEA9573F(a)microsoft.com... > >I have 6 NT servers with about 300 printers each on them. I need to > >migrate > > these printers to a 2003 box. I have a couple of scripts from Script > > Center > > that add a printer, add a port, list port properties and list printer > > capabilities. The only problem is that NT only supports the List printer > > capabilitites. Does anyone know of a way that I can pull the necessary > > port > > and printer information from my NT servers so that I can add them back to > > my > > 2003 server via script. > > > > Here are the sample scripts I'm starting from: > > > > List Printer Capabilities: > > > > strComputer = "." > > Set objWMIService = GetObject("winmgmts:" _ > > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > > > > Set colInstalledPrinters = objWMIService.ExecQuery _ > > ("Select * from Win32_PrinterConfiguration") > > > > For Each objPrinter in colInstalledPrinters > > Wscript.Echo "Name: " & objPrinter.Name > > Wscript.Echo "Collate: " & objPrinter.Collate > > Wscript.Echo "Copies: " & objPrinter.Copies > > Wscript.Echo "Driver Version: " & objPrinter.DriverVersion > > Wscript.Echo "Duplex: " & objPrinter.Duplex > > Wscript.Echo "Horizontal Resolution: " & _ > > objPrinter.HorizontalResolution > > If objPrinter.Orientation = 1 Then > > strOrientation = "Portrait" > > Else > > strOrientation = "Landscape" > > End If > > Wscript.Echo "Orientation : " & strOrientation > > Wscript.Echo "Paper Length: " & objPrinter.PaperLength / 254 > > Wscript.Echo "Paper Width: " & objPrinter.PaperWidth / 254 > > Wscript.Echo "Print Quality: " & objPrinter.PrintQuality > > Wscript.Echo "Scale: " & objPrinter.Scale > > Wscript.Echo "Specification Version: " & _ > > objPrinter.SpecificationVersion > > If objPrinter.TTOption = 1 Then > > strTTOption = "Print TrueType fonts as graphics." > > Elseif objPrinter.TTOption = 2 Then > > strTTOption = "Download TrueType fonts as soft fonts." > > Else > > strTTOption = "Substitute device fonts for TrueType fonts." > > End If > > Wscript.Echo "True Type Option: " & strTTOption > > Wscript.Echo "Vertical Resolution: " & objPrinter.VerticalResolution > > Next > > > > ******************************************************* > > > > List Port Properties > > > > strComputer = "." > > Set objWMIService = GetObject("winmgmts:" _ > > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > > > > Set colPorts = objWMIService.ExecQuery _ > > ("Select * from Win32_TCPIPPrinterPort") > > > > For Each objPort in colPorts > > Wscript.Echo "Description: " & objPort.Description > > Wscript.Echo "Host Address: " & objPort.HostAddress > > Wscript.Echo "Name: " & objPort.Name > > Wscript.Echo "Port Number: " & objPort.PortNumber > > Wscript.Echo "Protocol: " & objPort.Protocol > > Wscript.Echo "SNMP Community: " & objPort.SNMPCommunity > > Wscript.Echo "SNMP Dev Index: " & objPort.SnMPDevIndex > > Wscript.Echo "SNMP Enabled: " & objPort.SNMPEnabled > > Next > > ****************************************************** > > Install a Printer: > > > > strComputer = "." > > Set objWMIService = GetObject("winmgmts:" _ > > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > > > > Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_ > > > > objPrinter.DriverName = "HP LaserJet 4000 Series PS" > > objPrinter.PortName = "IP_169.254.110.160" > > objPrinter.DeviceID = "ScriptedPrinter" > > objPrinter.Location = "USA/Redmond/Building 37/Room 114" > > objPrinter.Network = True > > objPrinter.Shared = True > > objPrinter.ShareName = "ScriptedPrinter" > > objPrinter.Put_ > > > > ***************************************************** > > Install a Printer Port: > > > > Set objWMIService = GetObject("winmgmts:" _ > > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > > Set objNewPort = objWMIService.Get _ > > ("Win32_TCPIPPrinterPort").SpawnInstance_ > > > > objNewPort.Name = "IP_169.254.110.14" > > objNewPort.Protocol = 1 > > objNewPort.HostAddress = "169.254.110.14" > > objNewPort.PortNumber = "9999" > > objNewPort.SNMPEnabled = False > > objNewPort.Put_ > > > > > > -- > > Thanks for the help! > > Brian > > >
From: Steve Seguis [MVP] on 27 Feb 2005 23:04 Hi Brian, Sorry I didn't get back to you right away. Sounds like a pretty interesting problem but the solutions also seems fairly straight forward. I'm fairly confident you can accomplish the task by exporting (or scripting the query of) HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers. -- Steve Seguis - MCSE, MVP Windows Server, SCJP SCRIPTMATION, INC. Automating the Enterprise http://www.scriptmation.com "Brian" <Brian(a)discussions.microsoft.com> wrote in message news:CFFC78B6-C61E-401A-BFC6-D9E00C7B921D(a)microsoft.com... > Yes we use it quite often. Here's the deal. A couple of years ago we > realized that when we installed let's say 200 printers we maxed out the > registery and the server would crash. Microsoft gave us a patch that > split > the printer section into two parts and allowed for a bigger registery so > we > could install 300 printers. Now when we run the printmig tool it get all > freaked out and doesn't understand how the printers are split. So I > really > just need some way to get the Port Name and IP address and then the Print > Driver name, Printer name, Printer location, and share name. Also I'm at > a > loss as to why the only sample script supported by NT is the List Printer > Capabilities. Can I install some sort of extensions or something on my NT > servers so I can run the other sample scripts against them? > > "Steve Seguis [MVP]" wrote: > >> Have you looked at the printmig.exe tool from the Windows Resource Kit? >> >> -- >> Steve Seguis - MCSE, MVP Windows Server, SCJP >> SCRIPTMATION, INC. >> Automating the Enterprise >> http://www.scriptmation.com >> >> >> "Brian" <Brian(a)discussions.microsoft.com> wrote in message >> news:E74AA925-04EA-45E4-8A5D-00D4BEA9573F(a)microsoft.com... >> >I have 6 NT servers with about 300 printers each on them. I need to >> >migrate >> > these printers to a 2003 box. I have a couple of scripts from Script >> > Center >> > that add a printer, add a port, list port properties and list printer >> > capabilities. The only problem is that NT only supports the List >> > printer >> > capabilitites. Does anyone know of a way that I can pull the necessary >> > port >> > and printer information from my NT servers so that I can add them back >> > to >> > my >> > 2003 server via script. >> > >> > Here are the sample scripts I'm starting from: >> > >> > List Printer Capabilities: >> > >> > strComputer = "." >> > Set objWMIService = GetObject("winmgmts:" _ >> > & "{impersonationLevel=impersonate}!\\" & strComputer & >> > "\root\cimv2") >> > >> > Set colInstalledPrinters = objWMIService.ExecQuery _ >> > ("Select * from Win32_PrinterConfiguration") >> > >> > For Each objPrinter in colInstalledPrinters >> > Wscript.Echo "Name: " & objPrinter.Name >> > Wscript.Echo "Collate: " & objPrinter.Collate >> > Wscript.Echo "Copies: " & objPrinter.Copies >> > Wscript.Echo "Driver Version: " & objPrinter.DriverVersion >> > Wscript.Echo "Duplex: " & objPrinter.Duplex >> > Wscript.Echo "Horizontal Resolution: " & _ >> > objPrinter.HorizontalResolution >> > If objPrinter.Orientation = 1 Then >> > strOrientation = "Portrait" >> > Else >> > strOrientation = "Landscape" >> > End If >> > Wscript.Echo "Orientation : " & strOrientation >> > Wscript.Echo "Paper Length: " & objPrinter.PaperLength / 254 >> > Wscript.Echo "Paper Width: " & objPrinter.PaperWidth / 254 >> > Wscript.Echo "Print Quality: " & objPrinter.PrintQuality >> > Wscript.Echo "Scale: " & objPrinter.Scale >> > Wscript.Echo "Specification Version: " & _ >> > objPrinter.SpecificationVersion >> > If objPrinter.TTOption = 1 Then >> > strTTOption = "Print TrueType fonts as graphics." >> > Elseif objPrinter.TTOption = 2 Then >> > strTTOption = "Download TrueType fonts as soft fonts." >> > Else >> > strTTOption = "Substitute device fonts for TrueType fonts." >> > End If >> > Wscript.Echo "True Type Option: " & strTTOption >> > Wscript.Echo "Vertical Resolution: " & objPrinter.VerticalResolution >> > Next >> > >> > ******************************************************* >> > >> > List Port Properties >> > >> > strComputer = "." >> > Set objWMIService = GetObject("winmgmts:" _ >> > & "{impersonationLevel=impersonate}!\\" & strComputer & >> > "\root\cimv2") >> > >> > Set colPorts = objWMIService.ExecQuery _ >> > ("Select * from Win32_TCPIPPrinterPort") >> > >> > For Each objPort in colPorts >> > Wscript.Echo "Description: " & objPort.Description >> > Wscript.Echo "Host Address: " & objPort.HostAddress >> > Wscript.Echo "Name: " & objPort.Name >> > Wscript.Echo "Port Number: " & objPort.PortNumber >> > Wscript.Echo "Protocol: " & objPort.Protocol >> > Wscript.Echo "SNMP Community: " & objPort.SNMPCommunity >> > Wscript.Echo "SNMP Dev Index: " & objPort.SnMPDevIndex >> > Wscript.Echo "SNMP Enabled: " & objPort.SNMPEnabled >> > Next >> > ****************************************************** >> > Install a Printer: >> > >> > strComputer = "." >> > Set objWMIService = GetObject("winmgmts:" _ >> > & "{impersonationLevel=impersonate}!\\" & strComputer & >> > "\root\cimv2") >> > >> > Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_ >> > >> > objPrinter.DriverName = "HP LaserJet 4000 Series PS" >> > objPrinter.PortName = "IP_169.254.110.160" >> > objPrinter.DeviceID = "ScriptedPrinter" >> > objPrinter.Location = "USA/Redmond/Building 37/Room 114" >> > objPrinter.Network = True >> > objPrinter.Shared = True >> > objPrinter.ShareName = "ScriptedPrinter" >> > objPrinter.Put_ >> > >> > ***************************************************** >> > Install a Printer Port: >> > >> > Set objWMIService = GetObject("winmgmts:" _ >> > & "{impersonationLevel=impersonate}!\\" & strComputer & >> > "\root\cimv2") >> > Set objNewPort = objWMIService.Get _ >> > ("Win32_TCPIPPrinterPort").SpawnInstance_ >> > >> > objNewPort.Name = "IP_169.254.110.14" >> > objNewPort.Protocol = 1 >> > objNewPort.HostAddress = "169.254.110.14" >> > objNewPort.PortNumber = "9999" >> > objNewPort.SNMPEnabled = False >> > objNewPort.Put_ >> > >> > >> > -- >> > Thanks for the help! >> > Brian >> >> >>
From: Tarjei T. Jensen on 2 Mar 2005 02:49
"Brian" wrote: > So I really > just need some way to get the Port Name and IP address and then the Print > Driver name, Printer name, Printer location, and share name. Also I'm at a > loss as to why the only sample script supported by NT is the List Printer > Capabilities. Can I install some sort of extensions or something on my NT Have you tried to use PrnAdm.dll from a resource kit? I have used it to generate a list of printers with the information I need. I run the script on a windows 2003 server and the printers reside on a windows 2000 server. greetings, '* '* uses prnAdmin.dll '* option explicit const ForReading = 1 const kTcpRaw = 1 const kTcpLpr = 2 const kLocal = 3 const KLprMon = 5 const kHPdlc = 7 const kUnknown = 8 const theDelimiter = ";" dim oPort dim oMaster dim oPrinter dim oArgs dim oFSO '* File System Object dim objFile '* File to write dim strLine '* Text line dim strComputer dim strPrinter dim nameLen '* dim pShared dim wshShell Set oArgs = WScript.Arguments if 0 = oArgs.count then wscript.echo "Usage: " & WScript.ScriptName & " printer_server" wscript.quit end if strComputer = oArgs(0) if "\" <> left(strComputer,1) then strComputer = "\\" & strComputer end if if (not isCScript()) then set wshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "CScript.exe " & WScript.ScriptFullName WScript.Quit end if function isCScript() if (instr(ucase(WScript.FullName), "CSCRIPT") <> 0) then isCScript = true else isCScript = false end if end function set oPort = CreateObject("Port.Port.1") set oMaster = CreateObject("PrintMaster.PrintMaster.1") Set oFSO = CreateObject("Scripting.FileSystemObject") Set oArgs = WScript.Arguments for each oPrinter in oMaster.Printers(strComputer) select case left(oPrinter.PortName, 2) case "TS" case "LP" case "FI" case else 'wscript.echo " [" & oPrinter.PrinterName & "]" 'wscript.echo " [" & oPrinter.PortName & "]" 'wscript.echo " [" & strComputer & "]" oMaster.PortGet strComputer, oPrinter.PortName, oPort if "" <> oPrinter.ShareName then pShared = oPrinter.ShareName else pShared = "" end if strPrinter = oPrinter.PrinterName nameLen = len(strPrinter) strPrinter = right(strPrinter, nameLen - instrRev(strPrinter,"\",nameLen,vbTextCompare)) strLine = strPrinter & theDelimiter & _ oPort.PortType & theDelimiter & _ oPrinter.PortName & theDelimiter & _ oPrinter.DriverName & theDelimiter & _ oPrinter.Comment & theDelimiter & _ oPrinter.Location & theDelimiter & _ pShared wscript.echo strLine end select next |