hi,
i build a vb script to install a printer if not exist, but on some windows 7 (not all windows 7 client) i have this error:
Error: Invalid Index
Code: 8002000B
Origin: SWbemObjectEx
The portion ocde with error is this:
i put some echo to see where exactly the error start and:
1)if i change this line:
Set Printers = WshNetwork.EnumPrinterConnections
into
Set Printers = WshNetwork.EnumPrinterConnections()
the script go on , to second if statement
and if i insert an else:
the script go on and done all but when arrive at end sub,i have the error.
then i try to delete a part of code
2)if i delete cycle for--next, all go well(the content of cycle for not matter at all)
3)if i delete the second if --- enf if, all go well
someone could explain me?
thx
i build a vb script to install a printer if not exist, but on some windows 7 (not all windows 7 client) i have this error:
Error: Invalid Index
Code: 8002000B
Origin: SWbemObjectEx
The portion ocde with error is this:
Code:
........
sub GroupPrinterpadova1 ()
Set Printers = WshNetwork.EnumPrinterConnections
For i = 0 to Printers.Count - 1 Step 2
if Printers.Item(i+1)="\\srv-dc-01\PDPRINTER01 (RICOH Aficio MP 161 PCL6)" then
PrinterPD1=1
end if
next
if PrinterPD1<>1 then
WshNetwork.AddWindowsPrinterConnection "\\" & printpadova & "\PDPRINTER01"
end if
end sub
..............
i put some echo to see where exactly the error start and:
1)if i change this line:
Set Printers = WshNetwork.EnumPrinterConnections
into
Set Printers = WshNetwork.EnumPrinterConnections()
the script go on , to second if statement
and if i insert an else:
Code:
if PrinterPD1<>1 then
WshNetwork.AddWindowsPrinterConnection "\\" & printpadova & "\PDPRINTER01"
end if
into
if PrinterPD1<>1 then
WshNetwork.AddWindowsPrinterConnection "\\" & printpadova & "\PDPRINTER01"
[b]else[/b]
end if
the script go on and done all but when arrive at end sub,i have the error.
then i try to delete a part of code
2)if i delete cycle for--next, all go well(the content of cycle for not matter at all)
3)if i delete the second if --- enf if, all go well
someone could explain me?
thx