Jump to content

FileFindFirstFile in user provided path ?


Recommended Posts

Hi.

I was able to do script that display "Enter you path to application.exe".

After doing it, i want to search this given path for an *.exe files and if there won't be any .exe it means that path is invalid.

This is what i do:

If IsAdmin() Then
        $varmanual = InputBox("Ścierzka do katalogu", "Podaj ścieżkę do katalogu", "C:\Program Files\WinRar", "",-1, -1, 0, 0)
        If @error=1 Then
            Exit
        Else

        $search = FileFindFirstFile("winrar*.exe")

        ; Check if the search was successful
        If $search = -1 Then
            MsgBox(16, "Błąd", "W podanej ścieżce znalazłem pliku exe.")
            Exit
        Else
        ; Close the search handle
        FileClose($search)

        DirCopy(@SCriptDir, $varmanual, 1)
        FileCopy(@SCriptDir & "\*.*", $varmanual, 9)

        EndIf

but how to insert user-provided path as a parameter for FileFindFirstFile dir ?

Can i use this:

$search = FileFindFirstFile($varmanual & "winrar*.exe")
?
Link to comment
Share on other sites

If IsAdmin() Then
        $varmanual = InputBox("Scierzka do katalogu", "Podaj sciezke do katalogu", "C:\Program Files\WinRar\", "",-1, -1, 0, 0)
        If @error=1 Then
            Exit
        Else

        $search = FileFindFirstFile($varmanual &"winrar*.exe")
        EndIf
        ; Check if the search was successful
        If $search = -1 Then
            MsgBox(16, "Blad", "W podanej sciezce znalazlem pliku exe.")
            Exit
        Else
        ; Close the search handle
        FileClose($search)

        DirCopy(@SCriptDir, $varmanual, 1)
        FileCopy(@SCriptDir & "\*.*", $varmanual, 9)

        EndIf
    EndIf

You missed a "\" for the path. i added that at the first line

So you either do this

$varmanual = InputBox("Scierzka do katalogu", "Podaj sciezke do katalogu", "C:\Program Files\WinRar\", "",-1, -1, 0, 0)

or that

$search = FileFindFirstFile($varmanual &"\winrar*.exe")

Edited by Arterie
Link to comment
Share on other sites

You missed a "\" for the path. i added that at the first lineSo you either do this $varmanual = InputBox("Scierzka do katalogu", "Podaj sciezke do katalogu", "C:\Program Files\WinRar\", "",-1, -1, 0, 0)or that $search = FileFindFirstFile($varmanual &"\winrar*.exe")

Good catch, thank you. I was able to get -1 if no file found :-)

Check out the help file for: FileOpenDialog.

Thank you for providing better way to what i want to archive :>

P.S. Another great support board where i cannot hit "Thanks" fo users ? How it can be :unsure:

Edited by ALIENQuake
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...