burger Posted October 26, 2007 Posted October 26, 2007 I want to find an executable file and then run that file. The following code produces an error "Unable to execute the external program. Any ideas? ; Shows the filenames of all files in the current directory $search = FileFindFirstFile(@DesktopDir & "\TD file downloads\*.exe") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) Run($file,@DesktopDir & "\TD file downloads\") If @error Then ExitLoop MsgBox(4096, "File:", $file) WEnd ; Close the search handle FileClose($search)
GaryFrost Posted October 26, 2007 Posted October 26, 2007 Moved to correct part of forum. Doesn't belong in example scripts SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
guwguw Posted October 26, 2007 Posted October 26, 2007 I want to find an executable file and then run that file. The following code produces an error "Unable to execute the external program. Any ideas? ; Shows the filenames of all files in the current directory $search = FileFindFirstFile(@DesktopDir & "\TD file downloads\*.exe") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) Run($file,@DesktopDir & "\TD file downloads\") If @error Then ExitLoop MsgBox(4096, "File:", $file) WEnd ; Close the search handle FileClose($search)If there is only one *.exe, it'll never be run, because FileFindFirstFile(0 already found it and FileFindNextFile() is looking for the second "find".
burger Posted October 26, 2007 Author Posted October 26, 2007 There are 2 exe files in the directory. It runs neither one.
weaponx Posted October 26, 2007 Posted October 26, 2007 Your error is due to calling Run() on a folder name: Run($file,@DesktopDir & "\TD file downloads\") This needs to point to the found exe. Also, just use: #include <File.au3> $fileList = _FileListToArray ( @DesktopDir & "\TD file downloads\", "*.exe", 1) If $fileList[0] Then ;Run first found instance Run(@DesktopDir & "\TD file downloads\" & $fileList[1]) EndIf
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