---
title: "execute(completionHandler:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsuserscripttask/execute(completionhandler:)"
---

# execute(completionHandler:)

Executes the script with no input and ignoring any result.

## Declaration

```swift
func execute(completionHandler handler: NSUserScriptTask.CompletionHandler? = nil)
```

```swift
func execute() async throws
```

## Parameters

- `handler`: The completion handler Block that returns the result or an error. See doc://com.apple.foundation/documentation/Foundation/NSUserScriptTask/CompletionHandler.

## Discussion

Discussion This method should be invoked no more than once for a given instance of the class. If the script completed normally, the completion handler’s error parameter will be nil.

## See Also

### Related Documentation

- [init(url:)](foundation/nsuserscripttask/init(url:)-2qgls.md)
