Files.Launch
------------

Launches the file.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Files](component_Files.md) | [2.7](newinversion27.md) | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ❌ No |

MBS( "Files.Launch"; AppPath { ; DocPath...; NewInstance } ) 

**MBS**( **"Files.Launch";** /\* Launches the file. \*/  
**$AppPath**; /\* Native path to the application to launch.e.g. "/Applications/TextEdit.app" \*/   
**$DocPath...**; /\* Optional; Optional, Native path to the document to pass as argument.  
Must be text to distingush from flag, which are numbers.e.g. "/Users/cs/Desktop/Notes.rtf" \*/   
**$NewInstance**) /\* Optional; Whether to launch new app instance on Mac.  
Default is 0.e.g. 1 \*/ 

### 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 | Whether to launch new app instance on Mac.   Default is 0. | 1 | Optional      Added in version **7.2**. |

### 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](FilesAppPath.md) the path to your application. Then call Launch with that application path and your database file path.  
  
Please use [Files.LaunchFile](FilesLaunchFile.md) 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](component_Shell.md) 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](PathFileMakerPathToNativePath.md) 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](component_FileDialog.md) 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"; "/System/Applications/TextEdit.app"; "/Users/cs/Desktop/test.rtf"; "/Users/cs/Desktop/other.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](PathFileMakerPathToNativePath.md)"; $dbpath )\]  
Set Variable \[$apppath ; Value:MBS ( "[App.GetProcessPath](AppGetProcessPath.md)" )\]  
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

- [Files.ApplicationPathWithBundleIdentifier](FilesApplicationPathWithBundleIdentifier.md)
- [Files.LaunchFile](FilesLaunchFile.md)
- [Files.RevealFile](FilesRevealFile.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [Path.LastPathComponent](PathLastPathComponent.md)
- [PDFKit.Combine](PDFKitCombine.md)
- [PDFKit.Open](PDFKitOpen.md)
- [Shell.Execute](ShellExecute.md)
- [WordFile.AppendTableRow](WordFileAppendTableRow.md)
- [WordFile.ReplaceTag](WordFileReplaceTag.md)

### Release notes

- **Version 15.3**
    - Rewrote macOS part of [Files.LaunchFile](https://www.mbsplugins.eu/FilesLaunchFile.shtml) to use newer API on macOS 10.15 or higher.
- **Version 13.3**
    - Rewrote [Files.LaunchFile](https://www.mbsplugins.eu/FilesLaunchFile.shtml) function for macOS to use newer API.
- **Version 8.1**
    - Improved [Files.Launch](http://www.mbsplugins.eu/FilesLaunch.shtml) to better handle passing flag as text.
- **Version 7.2**
    - Added NewInstance parameter for [Files.LaunchFile](http://www.mbsplugins.eu/FilesLaunchFile.shtml) and [Files.Launch](http://www.mbsplugins.eu/FilesLaunch.shtml) function.

### Example Databases

- [Files/Launch](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Files/Launch.shtml#1GroupButton30.0000000420.000000055.0000000553.0000000LayoutObjectAnchor_)
- [Files/Open Database](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Files/Open%20Database.shtml#1GroupButton84.0000000270.0000000109.0000000391.0000000LayoutObjectAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 8.1pr1](https://www.mbsplugins.de/archive/2018-02-02/MBS_FileMaker_Plugin_version_8/monkeybreadsoftware_blog_filemaker)
- [Comparing Base Elements Plugin to MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2017-10-24/Comparing_Base_Elements_Plugin/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 7.2pr4](https://www.mbsplugins.de/archive/2017-04-26/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)
- [Restart FileMaker with same database](https://www.mbsplugins.de/archive/2017-04-21/Restart_FileMaker_with_same_da/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 5.3pr1](https://www.mbsplugins.de/archive/2015-08-26/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 4.2pr12](https://www.mbsplugins.de/archive/2014-06-21/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 2.7fc](https://www.mbsplugins.de/archive/2012-05-08/MBS_Filemaker_Plugin_version_2/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin 2.7 Release notes](https://www.mbsplugins.de/archive/2012-05-08/MBS_Filemaker_Plugin_27_Releas/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 2.7pr1](https://www.mbsplugins.de/archive/2012-03-26/MBS_Filemaker_Plugin_version_2/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 8th July 2025

  
[Files.ItemExists](FilesItemExists.md) - [Files.LaunchFile](FilesLaunchFile.md)

[HTML Version](FilesLaunch.shtml)