Alex_86_,
Попробуйте сделать так.
Код:
Global $aDrive, $sPath, $hSearch, $sFileExe, $sDirSearch = '\Windows\', $sDirExe = 'System32\'
;поменяйте имена папок $sDirSearch и $sDirExe на нужные Вам, например, на \WIN51\ и WPI\ как в Вашем примере.
$aDrive = DriveGetDrive('ALL')
If @error Then Exit MsgBox(16, 'Error', 'Ошибка поиска дисков', 5)
For $i = 1 To $aDrive[0]
If FileExists($aDrive[$i] & $sDirSearch) Then
$sPath = $aDrive[$i] & $sDirSearch
ExitLoop
EndIf
Next
If Not $sPath Then Exit MsgBox(16, 'Error', 'Ни на одном диске не найдена папка ' & $sDirSearch, 5)
$sPath &= $sDirExe
$hSearch = FileFindFirstFile($sPath & '*.exe')
If @error Then Exit MsgBox(16, 'Error', 'В папке ' & $sPath & ' не найдены файлы *.exe', 5)
While 1
$sFileExe = FileFindNextFile($hSearch)
If @extended Then ContinueLoop
If @error Then ExitLoop
ConsoleWrite($sPath & $sFileExe & @LF);смотрите в справке функции Run, RunWait, RunAs, RunAsWait, ShellExecute, ShellExecuteWait и тд...
WEnd