Creating Desktop Shortcut/Alias programmatically

  1. ‹ Older
  2. 3 years ago

    Michel B

    24 Jul 2016 Pre-Release Testers, Xojo Pro

    Hi Eugene,

    It works perfectly. Thank you :)

  3. Christian S

    24 Jul 2016 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    MBS Plugins also have classes for alias files on Mac and newer CFBookmarkMBS module.

    http://monkeybreadsoftware.net/module-cfbookmarkmbs.shtml

    For Windows we also have a class for creating shortcut files. And we have methods for hard and soft links.

    http://monkeybreadsoftware.net/class-windowsshortcutmbs.shtml

  4. Michel B

    24 Jul 2016 Pre-Release Testers, Xojo Pro
    Edited 3 years ago

    Well, Christian, I love your products, but finding anything on your site is even worse than the proverbial needle in the haystack. That is where I looked first, before giving up, after wasting about half an hour chasing the uncooperative wild goose.

    Thank you for the links, though.

  5. Christian S

    24 Jul 2016 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    Going on monkeybreadsoftware.net and entering Alias in the search finds it right away.
    Not sure where you looked for it.

  6. Richard D

    25 Jul 2016 Pre-Release Testers, Xojo Pro Europe (UK, London)

    something it is faster to just ask Christian

  7. Hello Christian. Using cfbookmarkmbs class to create an Alias is the same things to have a shell command like:

    ln -s /users/user/documents/Imyfolder /users/user/Desktop/myfolder.alias ?

    I got troubles, because Alias created by the class are not recognized from Dropbox. Alias created by cfbookmarkmbs are seen like simple files but ones created by the cmmand 'ln' are seen like folders and are put in synch with Dropbox....

    I'm stuck on this I m asking help to understand how to solve this issue. Thanks.

  8. Michel B

    8 Nov 2016 Pre-Release Testers, Xojo Pro
    Edited 3 years ago

    I am not sure this is the same. The command you show is a symbolic link, which can easily break if it is move, or if the target moves.

    I believe MBS creates real OS X aliases, which follow the target if it is moved.

    Now, the issue with DropBox may also come from the fact that intrinsically, DropBox is NOT OS X. Like most cloud systems, it is probably Linux. And Linux does snot know about osx aliases. Likewise, it does not deal very well with Windows shortcuts.

  9. Hello Michael. probably you are right, but the state of the art is creating a 'symbolik link' (at this point I think Alias is another thing)
    works and cfbookmarkmbs.CreateBookmarkData don't.

    ANy hint ?

  10. Michel B

    8 Nov 2016 Pre-Release Testers, Xojo Pro

    Then create symbolic link with a shell and be done with it.

    You don't seem to quite understand that Symbolic Link is a Unix/Linux thing, whereas an Alias is a feature of macOS which does much more, as it is attached to the target in a way that makes it able to follow it if it is moved, or even renamed. I would tend to believe the state of the art is the most powerful, which is macOS alias.

    But, most importantly, what do you want to do with Dropbox and symbolic links ? How are you stuck ?

  11. The point is. Sandbox App doesn't permit to use shell command execution. I need to create a symlink which is different from OSC Alias....the only way I found is cfbookmark but It doesn't give me the expected result....

  12. Christian S

    8 Nov 2016 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    Please be aware that we offer a lot of functions depending on platform or what you need (alias, soft link, hard link)

    MacAliasMBS class:
    http://www.monkeybreadsoftware.net/class-macaliasmbs.shtml

    CFBookmarkMBS module:
    http://www.monkeybreadsoftware.net/module-cfbookmarkmbs.shtml
    (see CFBookmarkMBS.WriteBookmarkDataToFile to write alias file)

    NSFileManagerMBS with createSymbolicLink and linkItem functions:
    https://www.monkeybreadsoftware.net/class-nsfilemanagermbs.shtml

    See also WindowsJunctionMBS for creating symbolic link for Windows:
    https://www.monkeybreadsoftware.net/module-windowsjunctionmbs.shtml

  13. Michel B

    8 Nov 2016 Pre-Release Testers, Xojo Pro
    Edited 3 years ago

    @Carlo DSimone The point is. Sandbox App doesn't permit to use shell command execution.

    Uh ? This topic has been explored several times in the forum. For my part, I have half a dozen apps currently in the MAS that use plain out of the box shell in sandbox to call Unix commands. A couple of them are actually simple UI wrappers for command line.

    However, you need to launch the shell with the Cocoa API if you want to use helpers, for instance. Sam Rowlands has posted the declare somewhere, but for myself, I simply use the MBS plugin LaunchServicesFindApplicationForInfoMBS .

  14. Edited 3 years ago

    The best solution for me is try to use NSFIlemanagerMBS. Hope App Wrapper doesn't cut off the code....It is for sure that this code:

      mShell = New Shell
      c = "ln -s '" + Replaceall(ff.shellpath,"\","") + "' " + DropBoxFolder.shellpath + "/'" + s +"'"
      
      mShell.Execute(c)

    Is cutted by App wrapper.....so sincerely I don't know how to use shell commands in the App Store....
    @Christian S I want to notice that:

    createSymbolicLink(path as string, destPath as string, byref error as NSErrorMBS) as boolean
    doesn't work as expected because I have an error....
    Instead if I use (note the parameters switch):

    createSymbolicLink(destPath as string,path as string, byref error as NSErrorMBS) as boolean

    It works.
    Now I have only to test if App Wrapper likes the code....
    Thanks

  15. Christian S

    8 Nov 2016 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    did I mix the parameters?
    oh sorry.
    I'll fix that soon.

  16. Edited 3 years ago

    Sorry Christian, About symlink and NSFilemanagerMBS Class, I read from docs:

    Special Considerations
    This method does not traverse symbolic links. If the item at the path is a symbolic link—that is, the value of the NSFileType key in the attributes dictionary is NSFileTypeSymbolicLink—you can use the destinationOfSymbolicLinkAtPath method to retrieve the path of the item pointed to by the link. You can also use the stringByResolvingSymlinksInPath method of NSString to resolve links in the path before retrieving the item's attributes.

    destinationOfSymbolicLinkAtPath is method of which class ? How to implement It ?
    THanks again for your precious help.

  17. Christian S

    8 Nov 2016 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    Sorry, destinationOfSymbolicLinkAtPath should be there in same class. I'll add it later for you.

  18. @ChristianSchmitz . Thank. It is very important for me. I got MBS 16.3
    it at ebarete dot it

  19. Christian S

    8 Nov 2016 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    new plugin sent. Enjoy!

  20. 2 years ago

    damon p

    19 Jun 2017 Pre-Release Testers, Xojo Pro

    hi Eugene
    many thanks worked great

  21. 4 months ago

    Jürg O

    Jul 30 Pre-Release Testers, Xojo Pro

    Just in case if someone is interested in an example project: CreateShortcut , which extends FolderItem.CreateShortcut(dest, caption, icon) for Windows/macOS/Linux (without using 3rd party Plugins).

or Sign Up to reply!