RunTask.Launch
--------------

Launches the task represented by the receiver.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [RunTask](component_RunTask.md) | [3.1](newinversion31.md) | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes, on macOS and Windows | ❌ No |

### Deprecated

This function was [deprecated](deprecated.md). Use [Shell](component_Shell.md) functions instead.

MBS( "RunTask.Launch" ) ### Parameters

none

### Result

Returns OK or error.

### Description

Launches the task represented by the receiver.  
If you get back an error with posix\_spawn and error 13, that's a permission denied.  
  
Please use [Shell.Execute](ShellExecute.md) if you need more features.  
  
For PowerShell scripts on Windows, you may need to check with the execution policy for the user account FileMaker is using or use an admin account. e.g. on FileMaker Server, may need to be installed as Admin user (not fmserver user).  
### Examples

Run ls on Mac:

 # new task   
Set Variable \[$r ; Value:MBS ( "[RunTask.NewTask](RunTaskNewTask.md)" )\]  
\#set launch path and arguments   
Set Variable \[$r ; Value:MBS ( "[RunTask.SetLaunchPath](RunTaskSetLaunchPath.md)"; "/bin/ls" )\]  
Set Variable \[$r ; Value:MBS ( "[RunTask.SetArguments](RunTaskSetArguments.md)"; "/bin" )\]  
\# run   
Set Variable \[$r ; Value:MBS ( "RunTask.Launch")\]  
\# wait   
Loop  
 Pause/Resume Script \[Duration (seconds): ,1\]  
 Exit Loop If \[MBS ( "[RunTask.IsRunning](RunTaskIsRunning.md)" ) ≠ 1\]  
End Loop  
\# read result   
Set Variable \[$data ; Value:MBS ( "[RunTask.ReadOutputText](RunTaskReadOutputText.md)"; "UTF-8" )\]  
Show Custom Dialog \["Result"; $data \]  
List connected clients on FileMaker Server:

 # © 30.07 .2016 Patrick Weh | Team Nifty GmbH (17:40 Uhr)   
\# List connected Clients   
\# ------------------------------------------------------------------------------------------------------------   
\# Script checks for connected clients at the FileMaker Server.   
\# Copy this File to your Server and run this Script on your FileMaker Server.   
\# ------------------------------------------------------------------------------------------------------------   
\#   
Set Error Capture \[On\]  
Allow User Abort \[Off\]  
\#   
Set Variable \[$r ; Value:MBS ( "[RunTask.NewTask](RunTaskNewTask.md)" )\]  
Set Variable \[$r ; Value:MBS ( "[RunTask.SetLaunchPath](RunTaskSetLaunchPath.md)"; "/Library/FileMaker Server/Database Server/bin/fmsadmin" )\]  
\# please put your admin password here   
Set Variable \[$r ; Value:MBS ( "[RunTask.SetArguments](RunTaskSetArguments.md)"; "-u" ; "fmserveradmin" ; "-p" ; "fmserveradminpassword" ; "list" ; "clients" ; "-s" )\]  
Set Variable \[$r ; Value:MBS ( "RunTask.Launch")\]  
\# now wait for task to finish:   
Set Variable \[$result ; Value:""\]  
Loop  
 Pause/Resume Script \[Duration (seconds): 2\]  
 Set Variable \[$result ; Value:$result &amp; MBS ("[RunTask.ReadOutputText](RunTaskReadOutputText.md)")\]  
 Exit Loop If \[MBS ("[RunTask.IsRunning](RunTaskIsRunning.md)") ≠ 1\]  
End Loop  
\#   
\# write into a field:   
Set Field \[Check clients::Clients ; $result \]  
Commit Records/Requests \[No dialog\]  
\#   
Run shell script in bash:

 Set Variable \[$r ; Value:MBS ( "[RunTask.NewTask](RunTaskNewTask.md)" )\]  
Set Variable \[$r ; Value:MBS ( "[RunTask.SetLaunchPath](RunTaskSetLaunchPath.md)"; "/bin/bash" )\]  
Set Variable \[$r ; Value:MBS ( "[RunTask.SetArguments](RunTaskSetArguments.md)"; "/Users/cs/Desktop/test.sh"; "First Param" )\]  
Set Variable \[$r ; Value:MBS ( "RunTask.Launch")\]  
Run something with shell to do redirect:

 Set Variable \[ $r ; Value: MBS ( "[RunTask.NewTask](RunTaskNewTask.md)" ) \]   
Set Variable \[ $r ; Value: MBS ( "[RunTask.SetLaunchPath](RunTaskSetLaunchPath.md)"; "/bin/bash" ) \]   
Set Variable \[ $r ; Value: MBS ( "[RunTask.SetArguments](RunTaskSetArguments.md)"; "-c"; "date &gt;/tmp/date.txt" ) \]   
Set Variable \[ $r ; Value: MBS ( "RunTask.Launch") \]   
Loop  
 Pause/Resume Script \[ Duration (seconds): ,1 \]   
 Exit Loop If \[ MBS ( "[RunTask.IsRunning](RunTaskIsRunning.md)" ) ≠ 1 \]   
End Loop  
Set Field \[ RunTask::Text ; MBS ( "[Text.ReadTextFile](TextReadTextFile.md)"; "/tmp/date.txt"; "UTF-8" ) \]  
Show quicklook preview window for PDF file:

 Set Variable \[ $r ; Value: MBS ( "[RunTask.NewTask](RunTaskNewTask.md)" ) \]   
Set Variable \[ $r ; Value: MBS ( "[RunTask.SetLaunchPath](RunTaskSetLaunchPath.md)"; "/usr/bin/qlmanage" ) \]   
Set Variable \[ $r ; Value: MBS ( "[RunTask.SetArguments](RunTaskSetArguments.md)"; "-p"; "/Users/cs/Desktop/Hello World.pdf" ) \]   
Set Variable \[ $r ; Value: MBS ( "RunTask.Launch") \]  
Run command with PowerShell:

 Set Variable \[ $r ; Value: MBS ("[RunTask.NewTask](RunTaskNewTask.md)") \]   
Set Variable \[ $r ; Value: MBS ("[RunTask.SetLaunchPath](RunTaskSetLaunchPath.md)"; "powershell.exe") \]   
Set Variable \[ $r ; Value: MBS ("[RunTask.SetArguments](RunTaskSetArguments.md)"; "-NoExit -command \\"Get-ExecutionPolicy -List\\"") \]   
Set Field \[ RunTask Windows::Result ; MBS ("RunTask.Launch") \]   
\#   
\# You need first to run via powershell as admin those commands to enable execution of powershell from FileMaker:   
\# Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine   
\# Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser   
### See also

- [RunTask.IsRunning](RunTaskIsRunning.md)
- [RunTask.NewTask](RunTaskNewTask.md)
- [RunTask.ReadErrorText](RunTaskReadErrorText.md)
- [RunTask.SetArguments](RunTaskSetArguments.md)
- [RunTask.SetLaunchPath](RunTaskSetLaunchPath.md)
- [RunTask.SetVerb](RunTaskSetVerb.md)
- [RunTask.Wait](RunTaskWait.md)
- [Shell.Execute](ShellExecute.md)
- [Text.ReadTextFile](TextReadTextFile.md)
- [URLScheme.SetDefaultHandler](URLSchemeSetDefaultHandler.md)

### Example Databases

- [Shell/RunTask/Run Shell Script on Mac](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Shell/RunTask/Run%20Shell%20Script%20on%20Mac.shtml#1ScriptAnchor_)
- [Shell/RunTask/RunTask Windows](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Shell/RunTask/RunTask%20Windows.shtml#1ScriptAnchor_)
- [Shell/RunTask/RunTask with read and write on Mac](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Shell/RunTask/RunTask%20with%20read%20and%20write%20on%20Mac.shtml#1ScriptAnchor_)
- [Shell/RunTask/RunTask](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Shell/RunTask/RunTask.shtml#1ScriptAnchor_)

### Blog Entries

- [Tip of the day: Query connected clients on FileMaker Server by script](https://www.mbsplugins.de/archive/2016-08-17/Tip_of_the_day_Query_connected/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 3th May 2021

  
[RunTask.IsRunning](RunTaskIsRunning.md) - [RunTask.NewTask](RunTaskNewTask.md)

[HTML Version](RunTaskLaunch.shtml)