Sign in to follow this  
Followers 0
NMD2W

Please, any one help 2 get rid of this prob [ im a "new boy" here]

4 posts in this topic

;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")

Exit

EndIf

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

$attrib = FileGetAttrib($file)

If StringInStr($attrib, "h") Then

MsgBox(4096, "File:", $file)

EndIf

WEnd

FileClose($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")

Exit

EndIf

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

MsgBox(4096, "File:", $file)

WEnd

FileClose($search)

Share this post


Link to post
Share on other sites



Do you have errors ? What doesnt work ?

Where do you get "$attrib" from ?

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0