Jump to content

Get Filename ?


Recommended Posts

Hello,

i'd like to write a little Script, which updates my Virus-Definitions.

On a local Server a Program is running, which writes every day an definition-exe.

The problem is, that the version of the definition-exe is namend in the filename, like def24444.exe.

On every update, the filename varied.

I need the filename to run the program, i tested "run("def*.exe")", dont work.

So i tried to get the name via FileFindFirstFile(), but that returns 0 and no name :/

Some ideas?

Attention! English noob ^^

Link to comment
Share on other sites

This was taken directly from the help menu, and it worked fine for me.

FileChangeDir("set_the_directory_you_need_here")

; Shows the filenames of all files in the current directory, note that "." and ".." are returned.
$search = FileFindFirstFile("def*.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) 
    If @error Then ExitLoop
    
    MsgBox(4096, "File:", $file)
WEnd

; Close the search handle
FileClose($search)

You just need to select the directory it will be stored at, then it will display every file that matches the description. You will need to fine tune it to find the specific file you want though.

Nomad

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...