<!--
{
  "availability" : [
    "macOS: 10.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SystemConfiguration",
  "identifier" : "/documentation/SystemConfiguration/SCPreferencesSetComputerName(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "System Configuration"
    ],
    "preciseIdentifier" : "c:@F@SCPreferencesSetComputerName"
  },
  "title" : "SCPreferencesSetComputerName(_:_:_:)"
}
-->

# SCPreferencesSetComputerName(_:_:_:)

Sets the computer name preference to the specified name.

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

`TRUE` if successful; otherwise, `FALSE`.

## Discussion

To commit these changes to permanent storage you must call the [`SCPreferencesCommitChanges(_:)`](/documentation/SystemConfiguration/SCPreferencesCommitChanges(_:)) function. In addition, you must call the [`SCPreferencesApplyChanges(_:)`](/documentation/SystemConfiguration/SCPreferencesApplyChanges(_:)) function for the new name to become active.

---

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)