找回密码
 加入
搜索
查看: 2661|回复: 5

谁能帮我写一个能搜索每个盘符下面每个文件夹找到这个文件并执行它

  [复制链接]
发表于 2008-9-27 23:12:01 | 显示全部楼层 |阅读模式
谁能帮我写一个能搜索每个盘符下面每个文件夹直到找到这个文件并执行它
$var = DriveGetDrive( "FIXED" )
If NOT @error Then
        MsgBox(4096,"", "Found " & $var[0] & " drives")
        For $i = 1 to $var[0]
        If FileExists($var[$i]&"\123.bat") = 1 Then
Run( $var[$i]&"\123.bat")
EndIf
    Next
EndIf
这个代码只能找每个盘符的根目录。
所以不行啊。
老大能不能帮忙一下啊。
 楼主| 发表于 2008-9-27 23:20:13 | 显示全部楼层
Func _FindAndRun($Tag)
Local $i,$flag
Local $Partition,$Path
$flag=0
For $i=67 To 90
  $Partition=Chr($i)&":"
  If DriveStatus($Partition)="READY" Then
   If FileExists($Partition&"\"&$Tag) Then
    $flag=1
    $Path=$Partition&"\"&$Tag
    ExitLoop
   EndIf
  EndIf
Next
If $flag=1 Then
  RunWait($Path)
EndIf
Return $flag
EndFunc
要搜索的文件写在什么地方啊?
发表于 2008-9-28 09:12:11 | 显示全部楼层

#include <Constants.au3>
Opt("MustDeclareVars",1)

Dim $Drive, $File
$Drive = InputBox("输入", "请输入驱动器字符!(如:C)", "", "", 180, 80,-1, -1)
If @error Then Exit
$File = InputBox("输入", "请输入你要检测的文件名称!", "", "", 180, 80,-1, -1)
If @error Then Exit

_GetFileName()
Func _GetFileName()
Local $foo,$line,$lines
$foo = Run(@ComSpec & " /c dir /b /s /a " & $File, $Drive & ":\", @SW_HIDE, $STDOUT_CHILD)
$lines = ""
While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
     $lines &= $line
Wend
MsgBox(0,"test",$lines)
EndFunc
发表于 2008-9-28 09:43:43 | 显示全部楼层

#NoTrayIcon
#include-once
Opt("MustDeclareVars", 1)
#include <Constants.au3>

Dim $Drive, $I, $File

$File = InputBox("输入", "输入要查找的文件名:", "", "", 180, 80, -1, -1)
If @error Or $File = "" Then Exit

$Drive = DriveGetDrive("ALL")

For $I = 1 To $Drive[0]
        Local $foo, $line, $lines
        $foo = Run(@ComSpec & " /c dir /b /s /a " & $File, $Drive[$I] & "\", @SW_HIDE, $STDOUT_CHILD)
        ProcessWaitClose($foo)
        $lines = ""
                $line = StdoutRead($foo)
                If @error Then ExitLoop
                $lines &= $line
        If $lines = "" Then ContinueLoop
        ;MsgBox(0, "找到的文件:", $lines)
        FileWriteLine("Find.log" ,$lines)
Next

$I = 0
While 1
        $I = $I 1
        $File = FileReadLine("Find.log", $I)
        If @error Then ExitLoop
        ShellExecute($File, "", @ScriptDir, "", 1)
WEnd
FileDelete("Find.log")


[ 本帖最后由 liongodmien 于 2008-9-28 21:45 编辑 ]
发表于 2008-10-20 20:18:19 | 显示全部楼层
楼上的
while 1
    $i = $i 1
    $file = filereadline(:find.log,$i)

其中$i = $i 1 有错误发生!!

[ 本帖最后由 liyi-softs 于 2008-10-20 20:21 编辑 ]
发表于 2008-10-20 20:46:59 | 显示全部楼层
明显是$I=$I+1
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-23 11:21 , Processed in 0.079527 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表