Lonkero... thanks. I understand that part (I think) but then looking at my actual code, I'm not sure why its failing. I'd better post the actual code I've got. Basically it's using srvcheck.exe to generate a temp file listing shares and permissions on those shares for a server, and then parsing that file to give me a listing of those share details.

The file is generated in the format

quote:
\\server\share1
[tab][tab]BUILTIN\Administrators [tab] Full Control
[tab][tab]DOMAIN\Usergroup [tab] Change

\\server\share2
[tab][tab]BUILTIN\Administrators [tab] Full Control
[tab][tab]DOMAIN\Usergroup1 [tab] Change
[tab][tab]DOMAIN\Usergroup2 [tab] Read

\\server\share3 etc....

So my code, reading line by line, first checks whether I am reading the details for a new share, a new ACE, or the blank line in between shares.

Because I don't know how many shares, or permissions entries for each share I will have, I'm trying to build the results into an array of strings like this:

code:
$Share[0] = "\\server\share1"
$Share[1] = "BUILTIN\Administrators"
$Share[2] = "Full Control"
$Share[3] = "DOMAIN\Usergroup"
$Share[4] = "Change"

And then build these arrays, which will all be of different sizes, into a larger array called $Shares, where each element will represent a share on the server.

The code I'm currently working with is...

code:
$shellstr = "cmd.exe /c srvcheck.exe \\" + $computer + " > c:\shares.txt"
? $shellstr
Shell $shellstr
$x = Open(1,"c:\shares.txt")
$x = Readline(1)
$ShareCount = 0
While @ERROR = 0
$PermsCount = 0
If Instr($x,"\\")
$ShareCount = $ShareCount + 1
$Share[$PermsCount] = $x
$PermsCount = $PermsCount + 1
$x = Readline(1)
Endif
While Instr($x," ")
$x = Right($x,(Len($x)-2))
$y = Split($x," ")
$Share[$PermsCount] = $y[0]
$PermsCount = $PermsCount + 1
$Share[PermsCount] = $y[1]
$PermsCount = $PermsCount + 1
$x = Readline(1)
Loop
If $x = ""
$x = Readline(1)
Endif
If $ShareCount
$Shares[$ShareCount - 1] = $Share
Endif
Loop
$x = Close(1)

It falls over at the line $Share[$PermsCount] = $y[0]. I suppose this is because when I first use $y, $PermsCount is 0. What should I do to get around this - I don't see how I can declare the size of $Share in advance?

Thanks for the quick response,

Breaker

[ 22. October 2002, 12:28: Message edited by: Breaker ]
_________________________
================================================
Breaker