Shell.AddArgument
-----------------

Adds an argument.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Shell](component_Shell.md) | [7.5](newinversion75.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ❌ No |

MBS( "Shell.AddArgument"; ShellRef; Argument... ) 

**MBS**( **"Shell.AddArgument";** /\* Adds an argument. \*/  
**$ShellRef**; /\* The reference number from the shell.e.g. $shell \*/   
**$Argument...**) /\* The new argument.e.g. "-l" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| ShellRef | The reference number from the shell. | $shell |
| Argument... | The new argument. | "-l" |

### Result

Returns OK or error.

### Description

Adds an argument.  
This argument is added to the list of arguments passed first on each call to [Shell.Execute](ShellExecute.md).  
With version 8.3, you can add several arguments here.  
  
This function takes variable number of parameters. Pass as much parameters as needed separated by the semicolon in FileMaker.  
Please repeat Argument parameter as often as you need.  
### Examples

Adds an argument:

 MBS ( "Shell.AddArgument"; $shell ; "-v" )  
Send email via Outlook.exe with options via command line:

 Set Variable \[ $app ; Value: "C:\\Program Files (x86)\\Microsoft Office\\Office15\\OUTLOOK.EXE" \]   
Set Variable \[ $attachment ; Value: "C:\\Users\\Administrator\\Desktop\\test.jpg" \]   
Set Variable \[ $to ; Value: "to@test.com" \]   
Set Variable \[ $subject ; Value: "Test Email" \]   
Set Variable \[ $cc ; Value: "copy@test.com" \]   
Set Variable \[ $body ; Value: "Hello World" \]   
Set Variable \[ $shell ; Value: MBS ( "[Shell.New](ShellNew.md)" ) \]   
Set Variable \[ $s ; Value: MBS ( "Shell.AddArgument"; $shell ; "/c" ) \]   
Set Variable \[ $s ; Value: MBS ( "Shell.AddArgument"; $shell ; "ipm.note" ) \]   
If \[ not IsEmpty ( $attachment ) \]   
 Set Variable \[ $s ; Value: MBS ( "Shell.AddArgument"; $shell ; "/a" ) \]   
 Set Variable \[ $s ; Value: MBS ( "Shell.AddArgument"; $shell ; $attachment ) \]   
End If  
Set Variable \[ $s ; Value: MBS ( "Shell.AddArgument"; $shell ; "/m" ) \]   
Set Variable \[ $a1 ; Value: MBS ( "[Text.EncodeURLComponent](TextEncodeURLComponent.md)"; $to ; "UTF-8" ) \]   
Set Variable \[ $a2 ; Value: "?subject=" &amp; MBS ( "[Text.EncodeURLComponent](TextEncodeURLComponent.md)"; $subject ; "UTF-8" ) \]   
Set Variable \[ $a3 ; Value: If ( Length ( $cc ) &gt; 0 ; "&amp;cc=" &amp; MBS ( "[Text.EncodeURLComponent](TextEncodeURLComponent.md)"; $cc ; "UTF-8" ); "" ) \]   
Set Variable \[ $a4 ; Value: If ( Length ( $body ) &gt; 0 ; "&amp;body=" &amp; MBS ( "[Text.EncodeURLComponent](TextEncodeURLComponent.md)"; $body ; "UTF-8" ) ; "") \]   
Set Variable \[ $s ; Value: MBS ( "Shell.AddArgument"; $shell ; $a1 &amp; $a2 &amp; $a3 &amp; $a4 ) \]   
Set Variable \[ $s ; Value: MBS ( "[Shell.Execute](ShellExecute.md)"; $shell ; $app ) \]   
Set Variable \[ $r ; Value: MBS ("[Shell.Release](ShellRelease.md)"; $shell ) \]  
Adds three arguments:

 MBS ( "Shell.AddArgument"; $shell ; "-v"; "-r"; "-e" )  
Add parameters various ways:

 Set Variable \[ $shell ; Value: MBS ( "[Shell.New](ShellNew.md)" ) \]  
\# set some parameters to go always:   
Set Variable \[ $r ; MBS ( "[Shell.SetArguments](ShellSetArguments.md)"; $shell ; "-a"; "test" )  
\# add optional parameter   
If \[ $Verbose \]  
 Set Variable \[ $r ; MBS ( "Shell.AddArgument"; $shell ; "-v" )  
End If  
\# now run command here and pass some more parameters   
Set Variable \[ $s ; Value: MBS ( "[Shell.Execute](ShellExecute.md)"; $shell ; $executable ; $InputFile ; $OutputFile ) \]  
### See also

- [Shell.Execute](ShellExecute.md)
- [Shell.GetArgument](ShellGetArgument.md)
- [Shell.GetArguments](ShellGetArguments.md)
- [Shell.New](ShellNew.md)
- [Shell.Release](ShellRelease.md)
- [Shell.SetArguments](ShellSetArguments.md)
- [Text.EncodeURLComponent](TextEncodeURLComponent.md)

### Example Databases

- [Shell/Shell Ping](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Shell/Shell%20Ping.shtml#1ScriptAnchor_)

### Blog Entries

- [Tips for FileMaker Data Migration Tool](https://www.mbsplugins.de/archive/2018-06-09/Tips_for_FileMaker_Data_Migrat/monkeybreadsoftware_blog_filemaker)
- [Convert to MP3 with new Shell commands and ffmpeg](https://www.mbsplugins.de/archive/2017-11-16/Convert_to_MP3_with_new_Shell_/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 11st November 2017 , last changed 15th September 2024

  
[SharingService.ShareValues](SharingServiceShareValues.md) - [Shell.AddEnvironment](ShellAddEnvironment.md)

[HTML Version](ShellAddArgument.shtml)