Jump to content

Recommended Posts

Posted (edited)

I am creating a script for work, that will clean out most viruses, but first I have to get all of the user names (to clean out temporary internet files).

Global $UserLoc = 'C:\Documents and Settings\', $WinTempLoc = 'C:\WINDOWS\Temp\', $Search, $User
Global $UserFolder[1]

$Search = FileFindFirstFile($UserLoc & '*')

While 1
    $User = FileFindNextFile($Search)
    If @error Then ExitLoop
    $UserFolder[0] += 1
    If UBound($UserFolder) <= $UserFolder[0] Then ReDim $UserFolder[UBound($UserFolder + 1)]
    $UserFolder[$UserFolder[0]] = $User
WEnd

Now, that does not work (there are 6 folders in my C:\Documents and Settings\ directory). I get this error:

C:\Documents and Settings\Chris\Desktop\Tune Up [XP]\Tune Up [XP].au3 (21) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$UserFolder[$UserFolder[0]] = $User
^ ERROR

This though, does:

Global $UserLoc = 'C:\Documents and Settings\', $WinTempLoc = 'C:\WINDOWS\Temp\', $Search, $User
Global $UserFolder[7]

$Search = FileFindFirstFile($UserLoc & '*')

While 1
    $User = FileFindNextFile($Search)
    If @error Then ExitLoop
    $UserFolder[0] += 1
    If UBound($UserFolder) <= $UserFolder[0] Then ReDim $UserFolder[UBound($UserFolder + 1)]
    $UserFolder[$UserFolder[0]] = $User
WEnd

The issue with this, is it limits it, I of course can have $UserFolder[256], but there is still that limitation, I want it to be able to expand.

Can someone help?

PS: I am aware of the _FileListToArry function, but it does not work either.

Edited by NoComment
Posted

Try ReDim $UserFolder[ubound($UserFolder)] or ReDim $UserFolder[ubound($UserFolder) + 1]

Thanks, rather than having the If statement, I put it as a standalone, and it works perfect now. Thank you.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...