leuce Posted November 6, 2011 Share Posted November 6, 2011 (edited) G'day everyone For what it's worth, I needed a way to extract the path of a file from an LNK file, and the following script does it. It works only on LNK files that you can see if you do a DIR command in the command prompt (some shortcuts don't seem to be LNK files). I haven't tested it extensively but it works on the files that I tested it on. The reason I wanted to do this was because I wanted to be able to copy or move a file from its current location to the locaiton of the shortcut. $fo = FileOpen ("myfile.lnk", 16) $fr = FileRead ($fo) For $i = 1 to BinaryLen ($fr) $character = BinaryMid ($fr, $i, 1) If $character = ":" Then $startpos = $i-1 ExitLoop EndIf Next For $j = $startpos to BinaryLen ($fr) $character = BinaryMid ($fr, $j, 1) If $character = "0x00" Then $endpos = $j-1 ExitLoop EndIf Next MsgBox (0, "", BinaryToString (BinaryMid ($fr, $startpos, $endpos - $startpos + 1)), 0) Samuel Edited November 6, 2011 by leuce Link to comment Share on other sites More sharing options...
trancexx Posted November 6, 2011 Share Posted November 6, 2011 FileGetShortcut() does this for you in case you were wondering. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
leuce Posted November 6, 2011 Author Share Posted November 6, 2011 FileGetShortcut() does this for you in case you were wondering. Thanks, I should have asked, shouldn't I? Link to comment Share on other sites More sharing options...
trancexx Posted November 6, 2011 Share Posted November 6, 2011 Thanks, I should have asked, shouldn't I? I think it's nice when people show initiative like you did with your code, regardless of necessity. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
matwachich Posted November 7, 2011 Share Posted November 7, 2011 Works for Shortcuts to files, not to folders And it doesn't get the commande line arguments By the way, nice example 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