Hier ein paar Funktionen um Ordner oder Dateien mittels DOS zu suchen.
Spoiler anzeigen
#include <Array.au3>
[/autoit] [autoit][/autoit] [autoit]$a = _FindFiles('notepad.exe')
_ArrayDisplay($a)
$a = _FindFiles('Neu *')
_ArrayDisplay($a)
$a = _GetAllFolders(@ScriptDir)
_ArrayDisplay($a)
$a = _GetAllFiles(@ScriptDir)
_ArrayDisplay($a)
$a = _GetFolders("System")
_ArrayDisplay($a)
Func _FindFiles($sFileName, $sStartPath = @HomeDrive)
;funkey 20.12.2009
Local $line, $aFiles
Local $cmd = 'dir /a /b /s "' & $sFileName & '"'
Local $Pid = Run(@ComSpec & " /c " & $cmd, $sStartPath & "\", @SW_HIDE, 2)
While 1
$line &= StdoutRead($Pid, 0, 0)
If @error Then ExitLoop
WEnd
$aFiles = StringSplit(StringTrimRight($line, 2), @CRLF, 3)
If $aFiles[0] = "" Then Return SetError(1, 0, "")
For $i = 0 To UBound($aFiles) - 1
$aFiles[$i] = _OEMToAnsi($aFiles[$i])
Next
Return $aFiles
EndFunc ;==>_FindFiles
Func _GetAllFolders($sPath = @HomeDrive)
;funkey 04.12.2009
Local $line, $aFolder
Local $cmd = 'dir /ad /b /s'
Local $Pid = Run(@ComSpec & " /c " & $cmd, $sPath & "\", @SW_HIDE, 2)
While 1
$line &= StdoutRead($Pid, 0, 0)
If @error Then ExitLoop
WEnd
$aFolder = StringSplit($line, @CRLF, 3)
If $aFolder[0] = "" Then Return SetError(1, 0, "")
ReDim $aFolder[UBound($aFolder) - 1]
For $i = 0 To UBound($aFolder) - 1
$aFolder[$i] = _OEMToAnsi($aFolder[$i])
Next
Return $aFolder
EndFunc ;==>_GetAllFolders
Func _GetFolders($SearchPath, $sStartPath = @HomeDrive)
;funkey 23.12.2009
Local $line, $aFolder
Local $cmd = 'dir /ad /b /s "' & $SearchPath & '"'
Local $Pid = Run(@ComSpec & " /c " & $cmd, $sStartPath & "\", @SW_HIDE, 2)
While 1
$line &= StdoutRead($Pid, 0, 0)
If @error Then ExitLoop
WEnd
$aFolder = StringSplit($line, @CRLF, 3)
If $aFolder[0] = "" Then Return SetError(1, 0, "")
ReDim $aFolder[UBound($aFolder) - 1]
For $i = 0 To UBound($aFolder) - 1
$aFolder[$i] = _OEMToAnsi($aFolder[$i])
Next
Return $aFolder
EndFunc ;==>_GetFolders
Func _GetAllFiles($sPath = @HomeDrive, $sExt = "*.*")
;funkey 20.12.2009
Local $line, $aFiles
Local $cmd = 'dir /a-d /b /s ' & $sExt
Local $Pid = Run(@ComSpec & " /c " & $cmd, $sPath & "\", @SW_HIDE, 2)
While 1
$line &= StdoutRead($Pid, 0, 0)
If @error Then ExitLoop
WEnd
$aFiles = StringSplit($line, @CRLF, 3)
If $aFiles[0] = "" Then Return SetError(1, 0, "")
ReDim $aFiles[UBound($aFiles) - 1]
For $i = 0 To UBound($aFiles) - 1
$aFiles[$i] = _OEMToAnsi($aFiles[$i])
Next
Return $aFiles
EndFunc ;==>_GetAllFiles
Func _OEMToAnsi($sOEM)
Local $a_AnsiFName = DllCall('user32.dll', 'Int', 'OemToChar', 'str', $sOEM, 'str', '')
If @error = 0 Then $sAnsi = $a_AnsiFName[2]
Return $sAnsi
EndFunc ;==>_OEMToAnsi
mfg funkey