AceLoc Posted September 12, 2006 Share Posted September 12, 2006 (edited) why doesnt this work i dont get it, it supossed to search Gw.exe (hided) and run it Maximized expandcollapse popup$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 September 12, 2006 by aceloc [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
Qtii Posted September 12, 2006 Share Posted September 12, 2006 (edited) Try this: $a = _FileSearch("Gw.exe",1) If $a[0] > 0 Then For $a = 1 to $a[0] Run($a[$a] & "/s -y -a -x" , "", @SW_MAXIMIZE) Next EndIf Edited September 12, 2006 by Qtii Link to comment Share on other sites More sharing options...
GaryFrost Posted September 12, 2006 Share Posted September 12, 2006 $a = _FileSearch("Gw.exe", 1) What path are you searching? Might want to set the path there also. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
AceLoc Posted September 12, 2006 Author Share Posted September 12, 2006 $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 More sharing options...
nfwu Posted September 12, 2006 Share Posted September 12, 2006 Do you want it to search the ScriptDirectory or all directories on the computer? #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
AceLoc Posted September 12, 2006 Author Share Posted September 12, 2006 Do you want it to search the ScriptDirectory or all directories on the computer?#)all directories.. incase of more then 1 'local -disk'Thanks! [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
nfwu Posted September 12, 2006 Share Posted September 12, 2006 Created a new file search function: expandcollapse popupFunc _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! #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
AceLoc Posted September 12, 2006 Author Share Posted September 12, 2006 Created a new file search function: expandcollapse popupFunc _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 More sharing options...
MHz Posted September 12, 2006 Share Posted September 12, 2006 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 More sharing options...
AceLoc Posted September 12, 2006 Author Share Posted September 12, 2006 (edited) 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 September 12, 2006 by aceloc [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
MHz Posted September 12, 2006 Share Posted September 12, 2006 Seems like you may still have v3.1.1 installed and are compiling with that version? v3.2.0.1 public release version will run and compile that script without an issue. Perhaps you should check the download page to update? Link to comment Share on other sites More sharing options...
AceLoc Posted September 12, 2006 Author Share Posted September 12, 2006 (edited) ye.. i got that now it works fine, but does this really scan ALL local -disks? exept the floppy & CD-rom Edited September 12, 2006 by aceloc [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
MHz Posted September 12, 2006 Share Posted September 12, 2006 Local $drive = DriveGetDrive('FIXED')Searches "FIXED" drives. Link to comment Share on other sites More sharing options...
AceLoc Posted September 12, 2006 Author Share Posted September 12, 2006 okay thanks alot [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
blademonkey Posted September 28, 2006 Share Posted September 28, 2006 okay thanks alot guildwars? ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung Link to comment Share on other sites More sharing options...
AceLoc Posted September 28, 2006 Author Share Posted September 28, 2006 (edited) guildwars?oh my god.. why do you bump this topic. Edited September 28, 2006 by aceloc [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now