Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Item Limit in Colections?

Status
Not open for further replies.

FloDiggs

MIS
Jan 20, 2007
296
US
Is there a limit to the number of items that can be placed in a collection in VBScript?
 
First, VBScript does not have collections per se.

if you are refering to arrays or dictionaries, then not that I am aware of. I imagine at some point you would run out of memory but I've never tried. Is there a specific reaseon that you are asking?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I am writing a script to find all of the MDBs on our main file server. I basically adapted the script from one I have been working on to find PST files. Both work find when searching PCs or the C: drive of the file server, but when pointed to the D: drive of the file server, which has about 600 GB of data on it, it croaks. Here is the simplest form of the code:

Code:
Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_DataFile Where Extension = 'mdb' AND Drive = 'D:'")

For Each objFile in colFiles
    Wscript.Echo objFile.Drive & objFile.Path & objFile.FileName & "." & objFile.Extension
Next
 
What do you mean by "croaks"? 600GB of files is going to take a long...long...long time to search.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
It errors out. It takes a little while to reproduce, but I'll reproduce it an provide the error.
 
Here's the error:

If run remotely:
(null): IDispatch error #3607

If run locally:
(null): IDispatch error #3607

The line it references is the start of the For Each statement.
 
Hmmm...I think that is an invalid query error but I don't see anything invalid in your query. I assume that D: is a physical drive on the machine that you are querying?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Yes, D: is a physical drive on that machine. I'm wondering if it has to do with the number of characters in a files path. There are some directories on the drive that get pretty long.
 
It would not suprise me at all to find that was the case. Windows has never been prticularly graceful with paths over 255 characters long.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
>Windows has never been prticularly graceful with paths over 255 characters

To be fair, the MAX_PATH length limitation is well documented - just not for VBScript programmers ...
 
Yeah, one of our developers came accross that. What we ended up doing was using robocopy.exe and using the switch to just log what it finds instead of actually copying the data. We then just parsed the log to get what we needed. Any ideas how Microsoft got around the MAX_LENGTH issue when writing Robocopy?
 
NTFS can actually handle much longer paths (32K). It is the ANSI versions of the various file functions in the Win32 API suffer from the MAX_PATH limit, and it is these that are used by many applications and libraries (e.g. the Shell, FileSystemObject) and thus enforce the limitation on client software.

Many of the ANSI functions have Unicode versions (e.g. CreateFileW instead of CreateFileA) which can be called instead and, if used with an additional prefix to the path of [blue]\\?\[/blue], give accesss to the 32K paths
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top