Jump to content

okay ired of trying


AceLoc
 Share

Recommended Posts

why doesnt this work i dont get it, it supossed to search Gw.exe (hided) and run it Maximized

$a = _FileSearch("Gw.exe", 1)
If $a[0] > 0 Then
    For $i = 1 to $a[0]
    Run($a[$i] & "/s -y -a -x" , "", @SW_MAXIMIZE)
    Next
EndIf

;--------------------------------------------

Func _FileSearch($szMask,$nOption)
    $szRoot = ""
    $hFile = 0
    $szBuffer = ""
    $szReturn = ""
    $szPathList = "*"
    Dim $aNULL[1]

    If Not StringInStr($szMask,"\") Then
         $szRoot = @SCRIPTDIR & "\"
    Else
         While StringInStr($szMask,"\")
              $szRoot = $szRoot & StringLeft($szMask,StringInStr($szMask,"\"))
              $szMask = StringTrimLeft($szMask,StringInStr($szMask,"\"))
         Wend
    EndIf
    If $nOption = 0 Then
         _FileSearchUtil($szRoot, $szMask, $szReturn)
    Else
         While 1
              $hFile = FileFindFirstFile($szRoot & "*.*")
              If $hFile >= 0 Then
                   $szBuffer = FileFindNextFile($hFile)
                   While Not @ERROR
                        If $szBuffer <> "." And $szBuffer <> ".." And _
                             StringInStr(FileGetAttrib($szRoot & $szBuffer),"D") Then _
                             $szPathList = $szPathList & $szRoot & $szBuffer & "*"
                        $szBuffer = FileFindNextFile($hFile)
                   Wend
                   FileClose($hFile)
              EndIf
              _FileSearchUtil($szRoot, $szMask, $szReturn)
              If $szPathList == "*" Then ExitLoop
              $szPathList = StringTrimLeft($szPathList,1)
              $szRoot = StringLeft($szPathList,StringInStr($szPathList,"*")-1) & "\"
              $szPathList = StringTrimLeft($szPathList,StringInStr($szPathList,"*")-1)
         Wend
    EndIf
    If $szReturn = "" Then
         $aNULL[0] = 0
         Return $aNULL
    Else
         Return StringSplit(StringTrimRight($szReturn,1),"*")
    EndIf
EndFunc

Func _FileSearchUtil(ByRef $ROOT, ByRef $MASK, ByRef $RETURN)
    $hFile = FileFindFirstFile($ROOT & $MASK)
    If $hFile >= 0 Then
         $szBuffer = FileFindNextFile($hFile)
         While Not @ERROR
              If $szBuffer <> "." And $szBuffer <> ".." Then _
                   $RETURN = $RETURN & $ROOT & $szBuffer & "*"
              $szBuffer = FileFindNextFile($hFile)
         Wend
         FileClose($hFile)
    EndIf
EndFunc
Edited by aceloc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Link to comment
Share on other sites

$a = _FileSearch("Gw.exe", 1)

What path are you searching?

Might want to set the path there also.

is that really needed.. its ment to search the exe

because.. it could be all other path's in all different language's

so isnt there an other way then??

Thanks!

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Link to comment
Share on other sites

Created a new file search function:

Func _FileSearchAllDirectories($szMask)
    $szRoot = ""
    $hFile = 0
    $szBuffer = ""
    $szReturn = ""
    $szPathList = "*"
    Dim $aNULL[1]
    For $i = Asc('a') To Asc('z')
         If Not FileExists(Chr($i)&":\") Then ContinueLoop
         $szRoot = Chr($i)&":\"
         While 1
              $hFile = FileFindFirstFile($szRoot & "*.*")
              If $hFile >= 0 Then
                   $szBuffer = FileFindNextFile($hFile)
                   While Not @ERROR
                        If $szBuffer <> "." And $szBuffer <> ".." And _
                             StringInStr(FileGetAttrib($szRoot & $szBuffer),"D") Then _
                             $szPathList = $szPathList & $szRoot & $szBuffer & "*"
                        $szBuffer = FileFindNextFile($hFile)
                   Wend
                   FileClose($hFile)
              EndIf
              _FileSearchUtil($szRoot, $szMask, $szReturn)
              If $szPathList == "*" Then ExitLoop
              $szPathList = StringTrimLeft($szPathList,1)
              $szRoot = StringLeft($szPathList,StringInStr($szPathList,"*")-1) & "\"
              $szPathList = StringTrimLeft($szPathList,StringInStr($szPathList,"*")-1)
          Wend
    Next
    If $szReturn = "" Then
         $aNULL[0] = 0
         Return $aNULL
    Else
         Return StringSplit(StringTrimRight($szReturn,1),"*")
    EndIf
EndFunc

Func _FileSearchUtil(ByRef $ROOT, ByRef $MASK, ByRef $RETURN)
    $hFile = FileFindFirstFile($ROOT & $MASK)
    If $hFile >= 0 Then
         $szBuffer = FileFindNextFile($hFile)
         While Not @ERROR
              If $szBuffer <> "." And $szBuffer <> ".." Then _
                   $RETURN = $RETURN & $ROOT & $szBuffer & "*"
              $szBuffer = FileFindNextFile($hFile)
         Wend
         FileClose($hFile)
    EndIf
EndFunc

Have not tested. Hope it works!

#)

Link to comment
Share on other sites

Created a new file search function:

Func _FileSearchAllDirectories($szMask)
    $szRoot = ""
    $hFile = 0
    $szBuffer = ""
    $szReturn = ""
    $szPathList = "*"
    Dim $aNULL[1]
    For $i = Asc('a') To Asc('z')
         If Not FileExists(Chr($i)&":\") Then ContinueLoop
         $szRoot = Chr($i)&":\"
         While 1
              $hFile = FileFindFirstFile($szRoot & "*.*")
              If $hFile >= 0 Then
                   $szBuffer = FileFindNextFile($hFile)
                   While Not @ERROR
                        If $szBuffer <> "." And $szBuffer <> ".." And _
                             StringInStr(FileGetAttrib($szRoot & $szBuffer),"D") Then _
                             $szPathList = $szPathList & $szRoot & $szBuffer & "*"
                        $szBuffer = FileFindNextFile($hFile)
                   Wend
                   FileClose($hFile)
              EndIf
              _FileSearchUtil($szRoot, $szMask, $szReturn)
              If $szPathList == "*" Then ExitLoop
              $szPathList = StringTrimLeft($szPathList,1)
              $szRoot = StringLeft($szPathList,StringInStr($szPathList,"*")-1) & "\"
              $szPathList = StringTrimLeft($szPathList,StringInStr($szPathList,"*")-1)
          Wend
    Next
    If $szReturn = "" Then
         $aNULL[0] = 0
         Return $aNULL
    Else
         Return StringSplit(StringTrimRight($szReturn,1),"*")
    EndIf
EndFunc

Func _FileSearchUtil(ByRef $ROOT, ByRef $MASK, ByRef $RETURN)
    $hFile = FileFindFirstFile($ROOT & $MASK)
    If $hFile >= 0 Then
         $szBuffer = FileFindNextFile($hFile)
         While Not @ERROR
              If $szBuffer <> "." And $szBuffer <> ".." Then _
                   $RETURN = $RETURN & $ROOT & $szBuffer & "*"
              $szBuffer = FileFindNextFile($hFile)
         Wend
         FileClose($hFile)
    EndIf
EndFuncoÝ÷ Øv¯zz-µë-yÑè¥è­Âä³}ÿªê-y»­v¡j÷­¢ë¶¬¶§jëh×6$a = _FileSearchAllDirectories("Gw.exe", 1)
If $a[0] > 0 Then
    For $i = 1 to $a[0]
    Run($a[$i] & "/s -y -a -x" , "", @SW_MAXIMIZE)
    Next
EndIf

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Link to comment
Share on other sites

This will search all local fixed drives for a filename using Dir command & StdoutRead().

_FileSearchToRun('cw.exe', '/s -y -a -x')

Func _FileSearchToRun($filename, $parameters = '')
    ; Searches for a filename on every fixed drive. Returns the pid.
    Local Const $IDYES = 6
    Local $data, $split, $pid
    Local $drive = DriveGetDrive('FIXED')
    If Not @error Then
        For $i = 1 To UBound($drive) -1
            $pid = Run(@ComSpec & ' /c Dir ' & $drive[$i] & '\' & $filename & ' /B/S', '', @SW_HIDE, 2)
            Do
                $data &= StdOutRead($pid)
            Until @error
        Next
    Else
        Return SetError(2, 0, 0)
    EndIf
    $split = StringSplit(StringStripWS($data, 3), @CRLF, 1)
    If Not @error Then
        For $i = 1 To $split[0]
            If MsgBox(0x40024, 'Run ' & $i & ' of ' & $split[0], $split[$i]) = $IDYES Then
                Return Run($split[$i] & " " & $parameters, '', @SW_MAXIMIZE)
            EndIf
        Next
    Else
        Return Run($split[1] & " " & $parameters, '', @SW_MAXIMIZE)
    EndIf
    Return SetError(1, 0, 0)
EndFunc
Link to comment
Share on other sites

This will search all local fixed drives for a filename using Dir command & StdoutRead().

_FileSearchToRun('cw.exe', '/s -y -a -x')

Func _FileSearchToRun($filename, $parameters = '')
    ; Searches for a filename on every fixed drive. Returns the pid.
    Local Const $IDYES = 6
    Local $data, $split, $pid
    Local $drive = DriveGetDrive('FIXED')
    If Not @error Then
        For $i = 1 To UBound($drive) -1
            $pid = Run(@ComSpec & ' /c Dir ' & $drive[$i] & '\' & $filename & ' /B/S', '', @SW_HIDE, 2)
            Do
                $data &= StdOutRead($pid)
            Until @error
        Next
    Else
        Return SetError(2, 0, 0)
    EndIf
    $split = StringSplit(StringStripWS($data, 3), @CRLF, 1)
    If Not @error Then
        For $i = 1 To $split[0]
            If MsgBox(0x40024, 'Run ' & $i & ' of ' & $split[0], $split[$i]) = $IDYES Then
                Return Run($split[$i] & " " & $parameters, '', @SW_MAXIMIZE)
            EndIf
        Next
    Else
        Return Run($split[1] & " " & $parameters, '', @SW_MAXIMIZE)
    EndIf
    Return SetError(1, 0, 0)
EndFunc
ahhhhh this works great!!

but it dont work in a compiled .exe ... could you fix that?

or could you say how it could be made in an .exe :)

EDIT: i get this error:

Line 0 (File "C:\Couments and Settings\MMORPG\Destkop\Test.exe"):

$data &= StdOutRead($pid)

$data &= ^ERROR

Error: Unknown function name.

but i dont get that error in .au3 :confused:

Thanks!

Edited by aceloc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Link to comment
Share on other sites

ye.. i got that now it works fine, but does this really scan ALL local -disks? exept the floppy & CD-rom

Edited by aceloc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...