NMD2W Posted May 11, 2009 Posted May 11, 2009 ;When Script is saved other than C:\ it's is not working;$search = FileFindFirstFile("C:\*.exe") If $search = -1 Then MsgBox(0, "Error", "No files match the search pattern") ExitEndIfWhile 1 $file = FileFindNextFile($search) If @error Then ExitLoop $attrib = FileGetAttrib($file) If StringInStr($attrib, "h") Then MsgBox(4096, "File:", $file) EndIfWEndFileClose($search);; BUT THE FOLLOWING IS WORKING FINE WHERE EVER THE SCRIPT IS SAVED!;$search = FileFindFirstFile("C:\*.exe") If $search = -1 Then MsgBox(0, "Error", "No files match the search pattern") ExitEndIfWhile 1 $file = FileFindNextFile($search) If @error Then ExitLoop MsgBox(4096, "File:", $file)WEndFileClose($search)
Juvigy Posted May 11, 2009 Posted May 11, 2009 Do you have errors ? What doesnt work ? Where do you get "$attrib" from ?
rudi Posted May 11, 2009 Posted May 11, 2009 Hi. FileFindNextFile() will only return the file name, without the path. FileGetAttrib() will need the full file name, including the path. $path=@SystemDir & "\" ; add a trailing backslash. $path=StringReplace($path,"\\","\") ; in case macros return root directories, these will end with "\", so eliminate "\\" to "\" $Pattern="*.exe" ConsoleWrite($path & "\" & $Pattern & @CRLF) $search=FileFindFirstFile($path & $Pattern) if @error Then Exit while 1 $file=FileFindNextFile($search) if @error then ExitLoop $attrib=FileGetAttrib($path & $file) if StringInStr($attrib,"h") Then MsgBox(0,"Hidden file",$path & $file) Else ConsoleWrite($path & $file & @CRLF) EndIf WEnd Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE!
NMD2W Posted May 14, 2009 Author Posted May 14, 2009 thanks rudi and thankz 2 aaaaaaaalllllllllllllllllll yeah! itz workig well ________________________________________ I just started studyung AutoIt on the day i posted my doubt. goin well .......... c u aaalllllllllll
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