Skip to content

Instantly share code, notes, and snippets.

@asheroto
Created June 9, 2026 23:42
Show Gist options
  • Select an option

  • Save asheroto/ec3d00553b7915d43a74411cc27f53e5 to your computer and use it in GitHub Desktop.

Select an option

Save asheroto/ec3d00553b7915d43a74411cc27f53e5 to your computer and use it in GitHub Desktop.
Remap the Windows 11 Copilot hardware key to launch ChatGPT Desktop via the native CopilotKey registry policy. Run as admin; reverts cleanly with -Revert.

Set-CopilotKeyToChatGPT

PowerShell script that makes ChatGPT Desktop available as a target for the Windows 11 Copilot hardware key.

It finds ChatGPT's MSIX AUMID, writes the CopilotKey\SetCopilotHardwareKey policy under HKCU, verifies the value, and opens the "Customize Copilot key on the keyboard" settings page so you can pick ChatGPT. The policy makes ChatGPT available as a Copilot key choice; you still select it on that page to make it the active target. Run with -Revert to remove the option.

Requirements

  • Windows 11 with a Copilot hardware key
  • The MSIX build of ChatGPT Desktop, installed from the Microsoft Store or downloaded directly from openai.com/chatgpt/desktop/
  • Administrator rights. The policy lives under HKCU\Software\Policies, whose ACL only allows SYSTEM and Administrators to write, so elevation is required. Run the script from a PowerShell session opened with "Run as administrator"; it stops with an error if it is not elevated.

Usage

Apply the remapping:

.\Set-CopilotKeyToChatGPT.ps1

Preview the changes without writing anything:

.\Set-CopilotKeyToChatGPT.ps1 -WhatIf

Revert to the default Copilot key behavior:

.\Set-CopilotKeyToChatGPT.ps1 -Revert

Sign out and back in for the change to take effect.

What it does

  1. Confirms it is running as Administrator and stops with an error if not.
  2. Locates ChatGPT Desktop through Get-StartApps and resolves its AUMID to an installed MSIX package.
  3. Writes HKCU:\SOFTWARE\Policies\Microsoft\Windows\CopilotKey\SetCopilotHardwareKey set to ChatGPT's AUMID, which registers ChatGPT as a Copilot key choice.
  4. Reads the value back to verify it.
  5. Opens ms-settings:personalization-textinput-copilot-hardwarekey so you can select ChatGPT as the active choice.

Why it needs Administrator rights

The mapping is stored under HKCU\Software\Policies\Microsoft\Windows\CopilotKey. Even though that path is in your own user hive (HKCU), the entire Software\Policies subtree is reserved for Group Policy and ships with an ACL that grants write access only to SYSTEM and the Administrators group. A standard (unelevated) process can read those keys but not write them, which is why an unelevated run fails with Requested registry access is not allowed.

Most HKCU writes do not need elevation; this one does specifically because it targets the policy branch. The script writes there because SetCopilotHardwareKey is the documented Copilot-key policy that Windows reads to remap the key. When you change the key by hand in Settings, Windows itself writes the choice on your behalf, so you never hit the ACL directly.

Notes

  • Settings > Personalization > Text input > "Customize Copilot key on the keyboard" will not offer ChatGPT as a choice until this registry policy exists, so the script (or an equivalent registry edit) has to run first. The settings page is useful for confirming or switching the choice afterward, not for the initial setup.
  • The script only writes to HKCU, so it affects the current user.
  • An app shows up as a Copilot key choice only when it ships as a signed MSIX package registered as a Copilot hardware key provider, which is why a plain .exe build would not work.
#Requires -Version 5.1
<#
.SYNOPSIS
Remaps the Windows Copilot hardware key to launch ChatGPT Desktop.
.DESCRIPTION
Uses the native MDM/CSP registry policy (CopilotKey\SetCopilotHardwareKey)
to redirect the Copilot key to the ChatGPT Desktop MSIX app.
Requires ChatGPT to be installed via the MSIX package from the Microsoft Store
or the direct MSIX download from OpenAI.
You can also change this without the script: open Windows Settings >
Bluetooth & devices > "Customize Copilot key on the keyboard".
.PARAMETER Revert
Removes the remapping and restores the default Copilot key behavior.
.NOTES
Install ChatGPT Desktop from the Microsoft Store, or download the MSIX from:
https://openai.com/chatgpt/desktop/
#>
[CmdletBinding(SupportsShouldProcess)]
param(
[switch]$Revert
)
$ErrorActionPreference = 'Stop'
function Write-Step {
param([string]$Message)
Write-Host "`n==> $Message" -ForegroundColor Cyan
}
function Write-OK {
param([string]$Message)
Write-Host " [OK] $Message" -ForegroundColor Green
}
function Write-Fail {
param([string]$Message)
Write-Host " [!!] $Message" -ForegroundColor Red
}
function Write-Note {
param([string]$Message)
Write-Host " $Message" -ForegroundColor Gray
}
function Test-Administrator {
$Identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$Principal = New-Object Security.Principal.WindowsPrincipal($Identity)
return $Principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
function Open-CopilotKeySettings {
Read-Host "`n Press Enter to open the settings page and select ChatGPT (or Ctrl+C to skip)"
Write-Step "Opening Copilot key settings..."
try {
Start-Process "ms-settings:personalization-textinput-copilot-hardwarekey"
Write-OK "Opened Windows Settings > Customize Copilot key on the keyboard."
} catch {
Write-Fail "Could not open Windows Settings automatically: $($_.Exception.Message)"
Write-Note $SettingsHint
}
}
$RegistryPath = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CopilotKey'
$ValueName = 'SetCopilotHardwareKey'
$SettingsHint = "You can also change this in Windows Settings > Bluetooth & devices > `"Customize Copilot key on the keyboard`"."
# --- Require administrator ----------------------------------------------------
# The policy lives under HKCU\Software\Policies, whose ACL only grants write to
# SYSTEM and Administrators. Writing it therefore requires an elevated session.
if (-not (Test-Administrator)) {
Write-Fail "This script must be run as Administrator."
Write-Note "Close this window, right-click PowerShell, choose 'Run as administrator', then re-run the script."
exit 1
}
# --- Revert path -------------------------------------------------------------
if ($Revert) {
Write-Step "Reverting Copilot key to default behavior..."
if (-not (Test-Path $RegistryPath)) {
Write-OK "Nothing to revert - no CopilotKey policy is set."
Write-Note $SettingsHint
exit 0
}
$Existing = Get-ItemProperty -Path $RegistryPath -Name $ValueName -ErrorAction SilentlyContinue
if ($Existing -and $PSCmdlet.ShouldProcess("$RegistryPath\$ValueName", 'Remove registry value')) {
Remove-ItemProperty -Path $RegistryPath -Name $ValueName
Write-OK "Removed $ValueName."
} else {
Write-OK "No $ValueName value found."
}
# Remove the key too if it is now empty.
$Remaining = Get-Item -Path $RegistryPath | Select-Object -ExpandProperty Property
if (-not $Remaining -and $PSCmdlet.ShouldProcess($RegistryPath, 'Remove empty registry key')) {
Remove-Item -Path $RegistryPath
Write-OK "Removed empty registry key: $RegistryPath"
}
Write-Host "`n Reverted. Sign out and back in for the change to take effect." -ForegroundColor Green
Write-Note $SettingsHint
if (-not $WhatIfPreference) { Open-CopilotKeySettings }
exit 0
}
# --- Step 1: Find ChatGPT's AUMID --------------------------------------------
Write-Step "Locating ChatGPT Desktop MSIX installation..."
$ChatGPTApps = @(Get-StartApps -Name "ChatGPT" | Where-Object { $_.AppID -like "*!*" })
if ($ChatGPTApps.Count -eq 0) {
Write-Fail "ChatGPT Desktop (MSIX) was not found."
Write-Host @"
The Copilot key remapping requires the MSIX version of ChatGPT Desktop.
Install it from the Microsoft Store, or download the MSIX directly from:
https://openai.com/chatgpt/desktop/
After installing, re-run this script.
"@ -ForegroundColor Yellow
exit 1
}
if ($ChatGPTApps.Count -gt 1) {
Write-Note "Found $($ChatGPTApps.Count) ChatGPT entries; using the first:"
foreach ($AppEntry in $ChatGPTApps) { Write-Note " - $($AppEntry.Name): $($AppEntry.AppID)" }
}
$ChatGPTApp = $ChatGPTApps[0]
$ChatGPTAUMID = $ChatGPTApp.AppID
Write-OK "Found ChatGPT AUMID: $ChatGPTAUMID"
# Confirm the AUMID resolves to an installed MSIX package (not a stale Start entry).
$PackageFamily = ($ChatGPTAUMID -split '!')[0]
$Package = Get-AppxPackage | Where-Object { $_.PackageFamilyName -eq $PackageFamily }
if (-not $Package) {
Write-Fail "The Start menu entry exists but no matching MSIX package is installed."
Write-Note "Reinstall ChatGPT Desktop and re-run this script."
exit 1
}
Write-OK "Confirmed installed MSIX package: $($Package.Name)"
# --- Step 2: Write registry policy -------------------------------------------
Write-Step "Configuring CopilotKey registry policy..."
if (-not (Test-Path $RegistryPath)) {
if ($PSCmdlet.ShouldProcess($RegistryPath, 'Create registry key')) {
New-Item -Path $RegistryPath -Force | Out-Null
Write-OK "Created registry key: $RegistryPath"
}
} else {
Write-OK "Registry key already exists: $RegistryPath"
}
if ($PSCmdlet.ShouldProcess("$RegistryPath\$ValueName", "Set value to '$ChatGPTAUMID'")) {
Set-ItemProperty -Path $RegistryPath -Name $ValueName -Value $ChatGPTAUMID -Type String
Write-OK "Set $ValueName = $ChatGPTAUMID"
}
# --- Step 3: Verify ----------------------------------------------------------
Write-Step "Verifying registry entry..."
$VerifyValue = Get-ItemPropertyValue -Path $RegistryPath -Name $ValueName -ErrorAction SilentlyContinue
if ($VerifyValue -eq $ChatGPTAUMID) {
Write-OK "Verification passed."
Write-Host "`n ChatGPT is now available as a Copilot key option." -ForegroundColor Green
Write-Note "To finish, select ChatGPT under `"Customize Copilot key on the keyboard`" - the settings page opens next."
Write-Note "If the option or the key change does not take effect, restart Explorer to reload the shell:"
Write-Note " Stop-Process -Name explorer -Force (Explorer restarts automatically)"
Write-Note "or sign out and back in."
Write-Host ""
Open-CopilotKeySettings
} elseif ($WhatIfPreference) {
Write-Note "Skipped verification (-WhatIf)."
} else {
Write-Fail "Verification failed - the registry value does not match. Please check manually."
exit 1
}
@asheroto

Copy link
Copy Markdown
Author

@Elichika-Pendragon

Thanks for testing!

Good news: newer builds of the ChatGPT app register themselves as a Copilot key provider, so the script shouldn't be needed anymore. Update ChatGPT (Microsoft Store), run this script with -Revert as Administrator to remove the policy, then pick ChatGPT under Settings > Bluetooth & devices > "Customize Copilot key on the keyboard". The full list of options comes back, because the limited dropdown is a side effect of the policy, not of ChatGPT. If ChatGPT still isn't listed after updating, re-run the script and it'll force it in as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment