#include <Array.au3>
$ras = '*.txt'
$aReturn = _FileSearch(@HomeDrive, $ras)
If $aReturn[0] > 0 Then
_ArrayDisplay($aReturn)
Else
MsgBox(0, "", "Файлов с расширением " & $ras & " не найдено.", 10)
EndIf
Func _FileSearch($sPath, $sFileMask)
Local $sOut = StringToBinary("0"& @CRLF, 2), $aOut
Local $hDir = Run(@ComSpec & ' /U/C DIR "'& $sPath &'\'& $sFileMask &'" /S/B/A-D', @SystemDir, @SW_HIDE, 6)
While 1
$sOut &= StdoutRead($hDir, False, True)
If @error Then ExitLoop
Wend
$aOut = StringRegExp(BinaryToString($sOut,2), "[^\r\n]+", 3)
If @error Then Return SetError(1)
$aOut[0] = UBound($aOut)-1
Return $aOut
EndFunc