1

I want my program to launch another desktop application.

Tried shell execute (open appname) but it does not work.

Is there another way ?

Thank you in advance.

Mitch Match
  • 339
  • 4
  • 14

3 Answers3

5

Another possibility is use the standard Xojo FolderItem and use the Launch method.

Dim f as folderitem = specialfolder.applications.child("AppName")
if f <> nil and f.exists then
  f.launch
end

Reference Documentation: http://docs.xojo.com/index.php/SpecialFolder http://docs.xojo.com/index.php/FolderItem.Launch

BKeeney Software
  • 1,299
  • 6
  • 8
  • I totally forgot about FolderItem.Launch! This is definitely the best way, and cross platform too. – ianmjones Sep 10 '13 at 06:18
  • The only potential problem is if the application is not in the standard place, in that case you either have to find or already know where the application is, or switch to using the "open" command via shell. – ianmjones Sep 10 '13 at 06:24
1
dim s as new Shell
s.Execute("open -a ""Finder""")

' Check error code and do something about it...
if s.ErrorCode <> 0 then
  MsgBox("Error code: " + Str(s.ErrorCode) + EndOfLine + "Output: " + s.Result)
end if

Change "Finder" to whichever application you need, or build a string and pass that to s.Execute(). Be sure to include escaped quotes, especially if the application has spaces in its name.

ianmjones
  • 3,395
  • 1
  • 25
  • 26
0

I'm not familiar with Xojo, however "launching" an application on OS X is complicated. There are many things you need to consider, especially if it's already running.

I recommend you look into two possible options, either use Xojo's ability to launch call native C code to run one of the three -[NSWorkspace launchApplication...] methods: https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSWorkspace_Class/Reference/Reference.html#//apple_ref/doc/uid/20000391-SW23

Alternatively, use Apple's open command line tool:

/usr/bin/open -a "App Name"
/usr/bin/open -a "/Applications/App Name.app"
Abhi Beckert
  • 32,787
  • 12
  • 83
  • 110