Jump to content

FileGetShortcut and URL targets.


Recommended Posts

Hello everyone!

I'm writing a small script that will go through a hard drive, find all shortcuts (*.lnk) and then use the FileGetShortcut (or _FileGetShortcutEx found here: http://www.autoitscript.com/forum/index.ph...ilegetshortcut) function to check if the shortcut is broken or not. It works fine with shortcuts that have a target to check, but the problem arises when a shortcut's target is a website. At that time, FileGetShortcut and _FileGetShortcutEx will not return a valid target.

I read a webpage where an example was given on using IShellLink to get attributes from a shortcut, but haven't found a sample on how to get this to work under AutoIt. Does anyone know if this is possible? I want to use the built-in functions to check the easy ones (the local ones) and then hopefully check and see if the "failing" shortcuts are just shortcuts with URLs in the target. I can then chose to ignore these shortcuts or log them as an error.

Any help/advice would be greatly appreciated. Thank you all for your time!

J

Link to comment
Share on other sites

  • 7 months later...

JoeyJoJo, I've had this same problem in the past, and by looking at 3 different shortcut files with weblinks in them, I've seen a pattern develop. This is not 'fully' tested, and I'd like for you to take a look (using a hex editor) - at location 6A (106th byte into the file), and tell me if you see the URL address there (http:\\ whatnot). Let me know if you see it in Unicode format too - the 'text' view of a hex editor will show an empty space between each character (WinHex shows 'h.t.t.p.:././.' etc).

I've written a routine that checks to see if a LNK file doesn't point to a file/folder (based on the flag value) and if not, it pulls a unicode string from 6A. So far it's worked pretty well for these tricky .LNK shortcuts that really should have been made into .URL's (drove me bonkers that they were allowed to do that!)

Anyway, let me know :)

thx,

Ascend4nt

Edited by ascendant
Link to comment
Share on other sites

  • 3 months later...

Hi Ascend4nt,

Thanks for the func!

The output was over my head so I can't really provide you with any useful feedback beyond "it showed the right link at the end". For everything else I could only grunt and poke it with a stick. :D

This is probably a slightly obscure topic so the lack of comments up until now isn't surprising, but it's well worthy of them. I'll be keeping it in my collection as a "Pandora's Box" for when and if that explosion of info begins to make sense to me.

Adios!

Link to comment
Share on other sites

Dolemite,

I'm not sure what you're looking for. Are you looking to skip certain shortcut types as well? I've found there are numerous types of shortcuts - one to logical objects, ones to network shares, ones to folders, or ones with URL's embedded in them.

The 'LNK (Windows Shortcut) Disassembler' in my sig will give you information about the different ShellItemID types contained within the shortcut if you want to dig into that.

Otherwise, I've already created a function "_FileGetGUIDShortcuts" (not publicly released yet) that pulls out URLs, UNC (network share pointers), and GUID-only shortcuts (My Computer, Recycle Bin, etc). Let me know if thats what you're looking for.

Getting the advanced shortcuts is a bit more of a hassle, like specific Control-Panel item shortcuts and the like.

Anyway, let me know

Ascend4nt

Link to comment
Share on other sites

I'm writing a small script that will go through a hard drive, find all shortcuts (*.lnk) and then use the FileGetShortcut (or _FileGetShortcutEx found here: http://www.autoitscript.com/forum/index.ph...ilegetshortcut) function to check if the shortcut is broken or not. It works fine with shortcuts that have a target to check, but the problem arises when a shortcut's target is a website. At that time, FileGetShortcut and _FileGetShortcutEx will not return a valid target.

Get the "String" for location in the shortcut, then filter with something like this

$String = "www.Autoit3.com"

If StringInStr($String, "www.") Or StringInStr($String, ".com") Or StringInStr($String, ".net") Then
        Ping($String)
        If @error = 3 Then
            ;remove the bad shortcut
            MsgBox(4096, "Test", " The link has been removed   ", 5)
        EndIf
EndIf

... Just might want to check that the client is online first.

8)

NEWHeader1.png

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