Creating a shortcut in OSX

I am trying to create a shortcut to applications of my app. So I do the following

ln -s “” /Applications/

This does not seem to work in OSX, fine in linux?

anyone any ideas why? is it to do with bundles?

If MBS plugins is an option for you then you may want to have a look at CFBookmarkMBS.WriteBookmarkDataToFile.

I’m using it in code to create an Alias (Shortcut) to an SQLite database file like this:

[code]Private Sub imFileCreateAliasToSQLite()
’ Last change: 09.02.2015
’ Author : Oliver Osswald
’ Purpose: Create a shortcut to a SQLite single user database
’ which is currently in use

// Store the reference to a FolderItem
Dim file As FolderItem = imDB.imDBProps.imDBFile

If file <> Nil And file.Exists Then
Dim fName As String = file.NameWithoutExtensionMBS

#If TargetCocoa
    Dim Bookmark As String = CFBookmarkMBS.CreateBookmarkData(file, CFBookmarkMBS.kCreationSuitableForBookmarkFile)
    Dim dlg as New SaveAsDialog
    Dim AliasFile As FolderItem
    dlg.SuggestedFileName=fName + " alias"
    If AliasFile = Nil then
      //user canceled
    End if
    If AliasFile <> Nil then
      If Not CFBookmarkMBS.WriteBookmarkDataToFile(Bookmark, AliasFile, 0) Then
        Dim e As CFErrorMBS = CFBookmarkMBS.lasterror
        MsgBox arbStrings.Failed+" "+e.Description
      End If
    End if
  End Try

#If TargetWin32
  //Creates a shortcut (.lnk file) in the users %TEMP% directory named scName and pointing to scTarget. Returns
  //a FolderItem corresponding to the shortcut file. You must move the returned Shortcut file to the desired directory.
  //On error, returns Nil.
  Dim lnkObj As OLEObject
  Dim scriptShell As New OLEObject("{F935DC22-1CF0-11D0-ADB9-00C04FD58A0B}")
  If scriptShell <> Nil then
    lnkObj = scriptShell.CreateShortcut(SpecialFolder.Desktop.AbsolutePath + fName + ".lnk")
    If lnkObj <> Nil then
      lnkObj.Description = fName.Uppercase
      lnkObj.TargetPath = file.AbsolutePath
      lnkObj.WorkingDirectory = file.AbsolutePath
    End If
  End If

End If

End Sub

[quote=208892:@dave duke]I am trying to create a shortcut to applications of my app. So I do the following

ln -s “” /Applications/

This does not seem to work in OSX, fine in linux?

anyone any ideas why? is it to do with bundles?[/quote]

What you are attempting to create is a Symbolic link. But you got the syntax wrong. See

This works :

ln -s /Applications/

Note that symbolic links on Mac work because they are using the underlying Unix, but they are not the same thing as Aliases, which are a feature of Mac OS X itself. A symbolic link will break if you rename the target. An alias will not. The MBS plugin creates a true alias.

To add to Michel’s point, an alias will also track a target that’s moved within its volume whereas a symbolic link will not.

You had got the fucken parameters all messed up. Read the fucken manual :wink:

Is it not beautiful how certain profanities make it through the filters ? I was expecting !@#$% !

If you spell it right I’m sure it would :stuck_out_tongue:

You may be able to make a symlink to the executable and get it to launch.

I bow to your expertise, Sir. Please forgive the incorrigible frog from massacring your noble vernacular. I am so dumb as to believe what is posted on the Internet Urban Dictionary: fucken

Please enlighten the ignorant, and tell me the exact spelling of that particular profanity. I think if you post it as code, it will go through. Unless you mean it should not end in “en”, but rather in “ing” ? But would it not lose the flavor of street parlance ?

I did to and it works perfectly. I use Symlinks extensively on my web sites.

I guess you’ll need to use some form of encoding, hex, oct?