---
title: "SCPreferencesSetComputerName(_:_:_:)"
framework: systemconfiguration
role: symbol
role_heading: Function
path: "systemconfiguration/scpreferencessetcomputername(_:_:_:)"
---

# SCPreferencesSetComputerName(_:_:_:)

Sets the computer name preference to the specified name.

## Declaration

```swift
func SCPreferencesSetComputerName(_ prefs: SCPreferences, _ name: CFString?, _ nameEncoding: CFStringEncoding) -> Bool
```

## Parameters

- `prefs`: The preferences session.
- `name`: The computer name.
- `nameEncoding`: The encoding associated with the computer name.

## Return Value

Return Value TRUE if successful; otherwise, FALSE.

## Discussion

Discussion To commit these changes to permanent storage you must call the SCPreferencesCommitChanges(_:) function. In addition, you must call the SCPreferencesApplyChanges(_:) function for the new name to become active.

## See Also

### Setting Configuration Information

- [SCPreferencesSetLocalHostName(_:_:)](systemconfiguration/scpreferencessetlocalhostname(_:_:).md)
