<!--
{
  "availability" : [
    "macOS: 10.13.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Process/run(_:arguments:terminationHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTask(cm)launchedTaskWithExecutableURL:arguments:error:terminationHandler:"
  },
  "title" : "run(_:arguments:terminationHandler:)"
}
-->

# run(_:arguments:terminationHandler:)

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

```
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

An initialized `NSTask` object with the environment of the current process.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)