Sign in to follow this  
Followers 0
typeleven

get url fron lnk file

7 posts in this topic

Im trying to use FileGetShortcut() to get the url in a .lnk file but the first spot in the array is blank. with this function not work on internet shortcuts? is there something that will extract the url from an internet shortcut?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi

.url files are a different format than .lnk, so the FileGetShortCut() won't work on those. What you can try though is, since the .url's are built like INI-Files...

$url = IniRead("AutoIT.url", "InternetShortcut", "URL", "-1")
If $url = "-1" Then
    ConsoleWrite("There was an error" & @CRLF)
Else
    ConsoleWrite("The url points to: " & $url & @CRLF)
EndIf

My output from running the above is:

The url points to: http://www.autoitscript.com/

Cheers

Edited by tannerli

Share this post


Link to post
Share on other sites

Okay, this makes the whole thing a little more complicated...

In my understanding, this lnk is not targeted to an executable directly as normally, but to some function located inside shell32.dll (at least it looks like this when you open the file in a Hex-Editor and compare it to a "normal" lnk)

You also might want to compare it with a lnk generated by Microsoft Office setup, there you have a similar effect (But instead of shell32.dll, the GUID of the windows installer is called with some parameters)

I also consulted the official documentation for the lnk-format by microsoft to get a clue on this... but this document's only purpose seems to be to screw up the readers mind...

Long story short:

FileGetShortcut() fails because the target is not directly stored inside the lnkfile. The effort to read it anyway is probably beyond what you had in mind.

I for my part won't do this...

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

But these are .lnk files. Specifically they are made from the renamer.

I can do what you are saying with a .url file but this is a .lnk file that has a url in it... very strange. Here is a screen shot of it for you...

I have also attached the file to this post if you'd like to take a look at it.

Posted Image

lnk file.zip

Edited by typeleven

Share this post


Link to post
Share on other sites

I created a UDF to get this type of info from a .LNK file, as well as from MSI 'advertised shortcuts'. Its confusing with SHITEMID's and PIDL and whatnot, but basically shortcuts can point to just about anything it seems. You can have them point to 'fake' folders like the Recycle Bin or a Control Panel item and whatnot. UNC links are also issues. The code's a mess right now, but I might be persuaded to put it up. It will find URL's, GUID's and UNC paths, but it won't go any deeper (like extended UNC/GUID paths)..

Share this post


Link to post
Share on other sites

Might you? I dont care how messy it is if it works! can I put in a path name into a function and have it return the url? that would be perfect!

Share this post


Link to post
Share on other sites

Here you go: _FileGetShortcutEx

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