Sign in to follow this  
Followers 0
mattslav

how to create an internet link w/ FileCreateShortc

5 posts in this topic

I tried:

FileCreateShortcut ("http://www.yahoo.com", @USERPROFILEDIR & "\Favorites")

and it says the target cannot be found. What do I need to do?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

CreateURLShortcut (@DesktopDir & "\AutoIt.url", "http://www.autoitscript.com")


Func CreateURLShortcut ($File, $URL)
   $Content = "[InternetShortcut]" & @LF & "URL=" & $URL & @LF & @CRLF
   $OpenShortcut = FileOpen($File, 2)
   If $OpenShortcut = -1 Then
      FileClose($OpenShortcut)
      Return -1
   EndIf
   FileWrite($OpenShortcut, $Content)
   FileClose($OpenShortcut)
   Return 0
EndFunc ;==>CreateURLShortcut

Edited by SlimShady

Share this post


Link to post
Share on other sites

thanks buddy, i appreciate it

Share this post


Link to post
Share on other sites

Slim, you could of done that another way, specifically, in one line (Without even wrapping it in a function!).

IniWrite(@DesktopDir & "\AutoIt.url", "InternetShortcut", "URL", "www.autoitscript.com")

Also, until Jon changes it, calling FileClose() on a handle of -1 produces a script aborting error, so I don't recommend doing that.

Share this post


Link to post
Share on other sites

Also, until Jon changes it, calling FileClose() on a handle of -1 produces a script aborting error, so I don't recommend doing that.

<{POST_SNAPBACK}>

FileOpen($File, 2)

I assume the folder where the user wants the file to be written, is accessible.

The problem you mentioned often occurs when reading a file that doesn't exist.

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