2015-04-30 38 views

回答

0

如何SEACH和运行exe文件存在子目录

_FileListToArrayRec()内位于子文件夹(-files)。

我已经尝试使用runwait的路径名称工作正常,但我想搜索,因为我的子文件夹不断变化每天。

识别使用_FileListToArrayRec()关于文件夹,并相应地设置Run()的(或RunWait()的)第一个参数。

实施例:

#include <File.au3> 

Global Enum $RFS_ERROR_RUN = 2 

Global Const $g_sFileName = 'notepad.exe', _ 
      $g_sFilePath = 'C:\', _ 
      $g_sFileMsg = 'file   : "%s"\n(sub-)folder : "%s"\nlocated at : "%s"\n' 

_RunFromSubfolder($g_sFileName, $g_sFilePath) 

Func _RunFromSubfolder(Const $sFile, Const $sFolder) 
    Local  $sMessage = '' 
    Local  $iError = 0, _ 
       $iExtd = 0, _ 
       $iPID  = 0 
    Local Const $aItems = _FileListToArrayRec($sFolder, $sFile, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) 

    If @error Then 

     $iError = @error 
     $iExtd = @extended 

    Else 

     $sMessage = StringFormat($g_sFileMsg, $sFile, $sFolder, $aItems[1]) 
     $iExtd = $aItems[0] 
     $iPID  = Run($aItems[1]) 

     If @error Then 

      $iError = $RFS_ERROR_RUN 
      $iExtd = @error 

     EndIf 

     ConsoleWrite($sMessage) 

    EndIf 

    Return SetError($iError, $iExtd, $iPID) 
EndFunc 

控制台输出:

file   : "notepad.exe" 
(sub-)folder : "C:\" 
located at : "C:\...\...\notepad.exe"