working on a script for school lab and this is the last one i just can't figure out where the problem is. It prints out the computer, network, and user name but it does not do the printer info. It tells me subscript out of range. Can someone please help me figure this out.
'purpose: Displays computer name, domain name and user name.
' Displays a list of all printer connections
option explicit
'output basic network information about the user and computer
dim wshNetwork
Set wshNetwork = wscript.createobject("wscript.network")
wscript.echo WshNetwork.ComputerName _
& vbcr & WshNetwork.UserDomain _
& vbcr & WshNetwork.UserName
'List the printers attached to this computer
dim PrinterCollection, printerOutput, i
set PrinterCollection = WshNetwork.enumPrinterConnections
if PrinterCollection.length = 0 then
wscript.echo "no printers"
else
printerOutput = "Printers:" & VBCR
For i = 0 to PrinterCollection.Count - 1 Step 2
next
end if
printerOutput = printerOutput & "Port " & PrinterCollection.Item(i) _
& " = " & PrinterCollection.Item(i+1) & VBCR
wscript.echo printerOutput
'purpose: Displays computer name, domain name and user name.
' Displays a list of all printer connections
option explicit
'output basic network information about the user and computer
dim wshNetwork
Set wshNetwork = wscript.createobject("wscript.network")
wscript.echo WshNetwork.ComputerName _
& vbcr & WshNetwork.UserDomain _
& vbcr & WshNetwork.UserName
'List the printers attached to this computer
dim PrinterCollection, printerOutput, i
set PrinterCollection = WshNetwork.enumPrinterConnections
if PrinterCollection.length = 0 then
wscript.echo "no printers"
else
printerOutput = "Printers:" & VBCR
For i = 0 to PrinterCollection.Count - 1 Step 2
next
end if
printerOutput = printerOutput & "Port " & PrinterCollection.Item(i) _
& " = " & PrinterCollection.Item(i+1) & VBCR
wscript.echo printerOutput