Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

Files.Launch

Launches the file.

Component Version macOS Windows Linux Server iOS SDK
Files 2.7 ✅ Yes ✅ Yes ❌ No ❌ No ❌ No
MBS( "Files.Launch"; AppPath { ; DocPath...; NewInstance } )   More

Parameters

Parameter Description Example Flags
AppPath Native path to the application to launch. "/Applications/TextEdit.app"
DocPath... Optional, Native path to the document to pass as argument.
Must be text to distingush from flag, which are numbers.
"/Users/cs/Desktop/Notes.rtf" Optional
NewInstance Available in MBS FileMaker Plugin 7.2 or newer.
Whether to launch new app instance on Mac.
Default is 0.
1 Optional

Result

Returns "OK" or error.

Description

Launches the file.
The OS will lookup what application is associated with the file type and launch the application asking it to open the document.
You can use this function to open a database file with FileMaker or your runtime solution. Query with Files.AppPath the path to your application. Then call Launch with that application path and your database file path.

Please use Files.LaunchFile to open a file and Files.Launch to open a file in a specific application.

Version 5.3 supports passing several DocPath parameters.
With version 7.2 the last parameter can be a number with 0 or 1 to define whether to run a new app instance.

Check also the Shell functions to run command line tools and get the output. This may work on the server, where the normal launch function may not work due to missing GUI.

This function requires a native path. Use Path.FileMakerPathToNativePath to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use FileDialog functions.

This function takes variable number of parameters. Pass as much parameters as needed separated by the semicolon in FileMaker.
Please repeat DocPath parameter as often as you need.

Examples

Launch two text files in Textedit:

MBS( "Files.Launch"; "/Applications/TextEdit.app"; "/Users/cs/Desktop/filme.rtf"; "/Users/cs/Desktop/test.rtf" )

Run notepad on Windows with a text file:

MBS( "Files.Launch"; "notepad.exe"; "C:\Users\Christian\Desktop\test2.txt")

Launch iMessages app:

MBS( "Files.Launch"; "/Applications/Messages.app")

Launch Mail application:

MBS( "Files.Launch"; "/Applications/Mail.app")

Restart FileMaker with same database:

Set Variable [$dbpath; Value:Get ( FilePath )]
Set Variable [$dbpath; Value:MBS( "Path.FileMakerPathToNativePath"; $dbpath )]
Set Variable [$apppath; Value:MBS( "App.GetProcessPath" )]
Set Variable [$r; Value:MBS( "Files.Launch"; $apppath; $dbpath; 1 )]
Exit Application

Open Website in Firefox on Windows:

MBS( "Files.Launch"; "C:\Program Files\Mozilla Firefox\Firefox.exe"; "http://www.mbsplugins.de" )

Open website in Google Chrome on Windows:

MBS( "Files.Launch"; "C:\Program Files (x86)\Google\Chrome\Application\Chrome.exe"; "http://www.mbsplugins.de" )

Launch System Events app:

MBS( "Files.Launch"; "/System/Library/CoreServices/System Events.app" )

See also

Release notes

Example Databases

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 5th June 2021


Files.ItemExists - Files.LaunchFile