Sign in to follow this  
Followers 0
keyfinger

FileGetShortcut does not retrieve url target info

14 posts in this topic

I'm running this simple script to try and retrieve the target path of this url (.lnk) file and it's coming back blank. Using beta version .124

#include <Array.au3>

FileCreateShortcut("http://www.autoitscript.com", @DesktopDir & "\AutoIT.lnk")

$details = FileGetShortcut(@DesktopDir & "\AutoIT.lnk")

_ArrayDisplay($details, "")

FileDelete(@DesktopDir & "\AutoIT.lnk")

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

put this in the script

$Url = "http://www.autoitscript.com/forum/index.php?act=idx"
        DllCall("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", &apos;open&apos;, "string", $Url, "string", &apos;&apos;, "string", @ScriptDir, "long", @SW_SHOWNORMAL)

then compile it

then create the shortcut... with your script

or create the shortcut within the script... then compile it

hey DEV's ... jon

the Autoit code tags create errors

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Getting an error when I try to compile.

DllCall("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", &

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Share this post


Link to post
Share on other sites

An internet shortcut is actually NOT a lnk file; it is a ini-formatted url file.

$url = IniRead("New Internet Shortcut.url", "InternetShortcut","URL", "ERROR")
MsgBox(0,"Result", $url)

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

Ok, then tell me how I do this with a .lnk file that has a url taget path. If I create the lnk with the url as the taget path, the file comes across as a .lnk not a .url like your example.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

the autoit code box created an error on my last post

$Url = "http://www.autoitscript.com/forum/index.php?act=idx"
DllCall("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", 'open', "string", $Url, "string", '', "string", @ScriptDir, "long", @SW_SHOWNORMAL)

try again... it wasn't me

8)

EDIT...

that works

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

You can use IniWrite in order to create the Internet Shortcut.

FilechangeDir(@DesktopDir)

IniWrite("Shortcut to AutoIt site.url", "InternetShortcut","URL","http://www.autoitscript.com")

$url = IniRead("Shortcut to AutoIt site.url", "InternetShortcut","URL", "ERROR")
MsgBox(0,"Result", $url)
Like I said, it's a URL file instead of LNK file. I don't know why Microsoft chose a different format, but the file type/extension is not LNK.

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

#8 ·  Posted (edited)

You can use IniWrite in order to create the Internet Shortcut.

FilechangeDir(@DesktopDir)

IniWrite("Shortcut to AutoIt site.url", "InternetShortcut","URL","http://www.autoitscript.com")

$url = IniRead("Shortcut to AutoIt site.url", "InternetShortcut","URL", "ERROR")
MsgBox(0,"Result", $url)
Like I said, it's a URL file instead of LNK file. I don't know why Microsoft chose a different format, but the file type/extension is not LNK.
@cyber...

I totally respect your knowledge and abilities. Your way is correct and probably the easiest. But my way will work also

I only posted again so that my script was correct and i could leave the incorrect info for someone to try and fix the code box

thanks

8)

EDIT

after fixing all of my spelling errors... can i blame it on the phone...lol

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Very interesting. You're right, the url extension works, but not the lnk extension. If I use the url extension, is there a way I can change the icon?

Share this post


Link to post
Share on other sites

Also, how come the filegetshortcut doesn't work the same for a url lnk as it does for a file lnk?

Share this post


Link to post
Share on other sites

Also, how come the filegetshortcut doesn't work the same for a url lnk as it does for a file lnk?

Because a URL is not a "lnk" file. The extension on a shortcut to a URL is url, not lnk. It's not the same type of file. They are both "shortcuts" but they are not the same type of shortcut.

They aren't the same, got it yet?

Share this post


Link to post
Share on other sites

No, what I was talking about is when I do a FileCreateShortcut and use a URL as the target, AutoIt creates a .lnk file. So my question is why doesn't FileGetShortcut work the same way with getting the target path of the .lnk file with a URL target vs a FILE target?

Try it, it doesn't create a .url file, it creates a .lnk file.

FileCreateShortcut(http://www.autoitscript.com, @DesktopDir & "\AutoIT.lnk")

Share this post


Link to post
Share on other sites

The answer to that question very likely lies in Redmond. I just tried every flag Microsoft provide for getting the path of a shortcut and none of them would return the URL. For whatever reason, it doesn't seem like the function we are using supports shortcuts with a URL.

Share this post


Link to post
Share on other sites

Alright, how about this then. If I create the .URL file, which I CAN retrieve the target path, then is there a way to change the icon using AutoIT? Anyone?

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