NoComment Posted November 22, 2009 Posted November 22, 2009 (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 WEndNow, 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 ^ ERRORThis 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 WEndThe 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 November 22, 2009 by NoComment
dantay9 Posted November 22, 2009 Posted November 22, 2009 Try ReDim $UserFolder[ubound($UserFolder)] or ReDim $UserFolder[ubound($UserFolder) + 1]
NoComment Posted November 22, 2009 Author Posted November 22, 2009 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now