Jump to content

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


Recommended Posts

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

Link to comment
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!

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

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