JoeyJoJo Posted July 7, 2008 Share Posted July 7, 2008 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 More sharing options...
Ascend4nt Posted February 15, 2009 Share Posted February 15, 2009 (edited) 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 February 15, 2009 by ascendant My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Dolemite50 Posted June 11, 2009 Share Posted June 11, 2009 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. 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 More sharing options...
Ascend4nt Posted June 11, 2009 Share Posted June 11, 2009 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 My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Valuater Posted June 11, 2009 Share Posted June 11, 2009 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) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now