最近寫了個刪除profile檔,老是報錯,高手看一下:
error:>"d:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "E:\新增AutoIt v3 Script.au3"
E:\??AutoIt v3 Script.au3 (33) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$a[$i] = FileReadLine($file)
^ ERROR
>Exit code: 1 Time: 2.780#include <File.au3>
#include <Array.au3>
Local $i, $a[1]
;Run DOS command to get user profile lists
Run(@COMSPEC & " ")
Send(" C: ")
Send("{ENTER}")
Send( "cd C:\Documents and Settings" )
Send("{ENTER}")
If FileExists("d:\user.txt") Then
Send(" dir /b >>d:\user.txt")
Send("{ENTER}")
Send(" Exit")
Send("{ENTER}")
Else
_FileCreate("d:\user.txt")
Send(" dir /b >>d:\user.txt")
Send("{ENTER}")
Send(" Exit")
Send("{ENTER}")
EndIf
; open user.txt, and write an array.
$file = FileOpen("d:\user.txt", 0 )
$CountLines = _FileCountLines("d:\user.txt")
MsgBox(64, "Error log recordcount", "There are " & $CountLines & " lines.")
ReDim $a[$CountLines]
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
For $i = 0 To $CountLines + 1 Step 1
$a[$i] = FileReadLine($file)
;_ArrayDisplay($a)
;MsgBox(0, "Line read:", $a[$i])
Next
MsgBox(0, "Error", "Unable to open file.")
;delete profile
For $i=0 To $CountLines Step 1
If $a[$i] = "Administrator" And $a[$i] = "All Users" And $a[$i] = "Default User" Then
DirRemove($a[$i + 1], 1)
Else
DirRemove($a[$i], 1)
EndIf
Next
FileClose($file)
|