Jump to content

how to create an internet link w/ FileCreateShortc


mattslav
 Share

Recommended Posts

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
Link to comment
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.

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...