---
title: "run(_:arguments:terminationHandler:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/process/run(_:arguments:terminationhandler:)"
---

# run(_:arguments:terminationHandler:)

Creates and runs a task with a specified executable and arguments.

## Declaration

```swift
class func run(_ url: URL, arguments: [String], terminationHandler: (@Sendable (Process) -> Void)? = nil) throws -> Process
```

## Parameters

- `url`: The URL for the executable.
- `arguments`: An array of NSString objects that supplies the arguments to the task. If arguments is nil, the system raises an NSInvalidArgumentException.
- `terminationHandler`: The system invokes this completion block when the task has completed.

## Return Value

Return Value An initialized NSTask object with the environment of the current process.

## See Also

### Creating and initializing a process

- [init()](foundation/process/init().md)
