Re: Scripting Printers
From: Tarjei T. Jensen (tarjei_at_online.no)
Date: 03/02/05
- Next message: Christian: "Re: Opening and Activating of Excel Workbooks with VBS/VBA"
- Previous message: Me: "Re: Script that lists users in a group and nested groups within that group."
- Maybe in reply to: Steve Seguis [MVP]: "Re: Scripting Printers"
- Messages sorted by: [ date ] [ thread ]
Date: 2 Mar 2005 08:49:52 +0100
"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
- Next message: Christian: "Re: Opening and Activating of Excel Workbooks with VBS/VBA"
- Previous message: Me: "Re: Script that lists users in a group and nested groups within that group."
- Maybe in reply to: Steve Seguis [MVP]: "Re: Scripting Printers"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|