---
title: "addScript"
canonical: "https://help.vicon.com/space/ShogunPost121/1253739298/addScript"
format: markdown
---
# Description

Adds a script to Shogun's internal list of scripts.

By default, Shogun fills its internal list with all of the hsl files found in the "script directories" you specify in your Preferences. However, if you wish to be able to call a script which isn't under one of those directories, then you must either use the [runScript](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737250) command, or you must add the script to Shogun's internal list of scripts using addScript.

Note that if you wish to call the script from a hot key, then you should use this command rather than [runScript](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737250).

Also note that if the file name of the script you add conflicts with an existing script or command in Shogun's internal list, then this command will fail. It will also fail if the script does not exist on the file system.

## Functional area

System

# Command syntax

## Syntax

> Macro (scroll-tablelayout)

|  |
| --- |
| `addScript "scriptPath"` |

### Arguments

> Macro (scroll-tablelayout)

| Name | Type | Required | Comments |
| --- | --- | --- | --- |
| `scriptPath` | string | yes | The full path of the script to add to Shogun's list of scripts. For paths, use forward-slashes instead of back-slashes (e.g. C:/My Documents/MyScript.hsl) |

### Flags

None 

## Return value

void

> Macro (scroll-pagebreak)

## Examples

```plaintext
// Iterate through all of the scripts in a directory and
// add them to Shogun's list of scripts
string $scripts[] = `getFileList "X:/My/Server/Scripts/" -pattern "*.hsl"`;
int $index, $count;
$count = `getCount $scripts`;
for( $index = 0; $index < $count; $index += 1 )
{
 addScript $scripts[ $index ];
```

# Additional information

## Related commands

- [addScriptPath](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738562)
- [clearScriptPaths](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737120)
- [deleteScriptPath](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737382)
- [getScriptPaths](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738493)
- [runScript](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738493)
- [scriptExists](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738212)
- [setScriptPaths](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738188)