The_ALL Posted September 1, 2010 Share Posted September 1, 2010 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 IndexCode: 8002000BOrigin: SWbemObjectExthis is the part of code with "error" for windows 7 ........sub GroupPrinterpadova1 ()Set Printers = WshNetwork.EnumPrinterConnectionsFor 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 ifnextif PrinterPD1<>1 thenWshNetwork.AddWindowsPrinterConnection "\\" & printpadova & "\PDPRINTER01"end ifend sub.............. i put some echo to see where exactly the error start and:1)if i change this line adding (): Set Printers = WshNetwork.EnumPrinterConnectionsintoSet Printers = WshNetwork.EnumPrinterConnections() the script go on , to second if statementand2)if i insert an else: if PrinterPD1<>1 thenWshNetwork.AddWindowsPrinterConnection "\\" & printpadova & "\PDPRINTER01"end ifintoif PrinterPD1<>1 thenWshNetwork.AddWindowsPrinterConnection "\\" & printpadova & "\PDPRINTER01"elseend 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 codeA)if i delete cycle for--next, all go well(the content of cycle for not matter at all)B)if i delete the second if --- enf if, all go wellsomeone could explain me?this error popup only on some windows 7 clientthxlorenzo Link to comment Share on other sites More sharing options...
The_ALL Posted September 6, 2010 Author Share Posted September 6, 2010 error found, simply declare i of Printers.Item(i) ........sub GroupPrinterpadova1 ()dim i Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.