Jump to content
Sign in to follow this  
mattslav

how to create an internet link w/ FileCreateShortc

Recommended Posts

mattslav

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
SlimShady

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
Valik

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
SlimShady

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.