Sign in to follow this  
Followers 0
jefhal

Let lying links lay

3 posts in this topic

I wrote a script that requires that I point to a file and then search for that file on a set of machines. This works fine for nearly every file type on a PC. However, when I use FileOpenDialog to point to a filename.lnk file, FileOpenDialog returns the path to the target file, not the shortcut itself. (Thanks Bill!)

Can anyone think of a way to open a file dialog box, point to a file, and retrieve the long filename, even if the file is a *.lnk one?

This code is more than you need, but I thought I'd put it in partial context:

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $chgtarfile Then
            $var = FileOpenDialog($message, "\\" & $strComputer & "\c$\program files" , "All Files (*.*)", 1 )
            GUICtrlSetData(3,"You chose " & $var)
            If @error Then
                MsgBox(4096,"","No File(s) chosen")
        Else
        ;$var = StringReplace($var, "|", @CRLF)
            MsgBox(4096,"","You chose " & $var)
            $file = FileOpen(@TempDir & "\IsInstalled.ini",2);open temp file for writing in d&s/jhall/local/temp
            FileWrite($file,$var)
        EndIf       
    EndIf

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites



Interesting. If the filter is *.* then it returns the target like you said.

However, if the filter is *.lnk, then it returns the actual LNK file path.

The following seems to work :lmao:

$var = FileOpenDialog("Example", @DesktopDir, "All Files (*;*.lnk)")
If Not @error Then MsgBox(4096,"","You chose " & $var)

FYI: Even though *;*.lnk works the way you want *.*;*.lnk does not.


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

FYI: Even though *;*.lnk works the way you want *.*;*.lnk does not.

Thank you CyberSlug! I tested the code today and it works perfectly!

Previously, the only near-solution was a real kludge, but it did not give me the same usability as your idea. With the kludge, you had to know the name of the file you were looking for. With yours I can still just browse the folder to find the best file to test for.

Best, Jeff

Edited by jefhal

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

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