大网数据广告活动
启动与系统组件

Error 0xC004F042 "The specified Key Management Service (KMS) can't be used" when activating Windows

· 52CE 我爱测

Describes how to troubleshoot and resolve error 0xC004F042 ("The specified Key Management Service (KMS) can't be used"). The steps apply to physical computers, on-premises virtual machines (VMs), and Azure VMs.

Summary

This article explains how to resolve error 0xC004F042 (The Software Licensing Service determined that the specified Key Management Service (KMS) cannot be used.). This error might occur if you have multiple KMS hosts that activate different sets of KMS clients. The troubleshooting steps in this article apply to physical computers, on-premises virtual machines (VMs), and Azure VMs.

Symptoms

When you try to activate a Windows system, you see the following error message in Windows Script Host:

**Error: 0xC004F042** The Software Licensing Service determined that the specified Key Management Service (KMS) cannot be used.

Cause

This error occurs if the KMS client contacts a KMS host that can't activate the client software. This scenario is common in mixed environments that have application-specific and operating system-specific KMS hosts.

This error typically occurs in the following scenarios:

  • You configure the KMS client to contact a self-hosted KMS server that doesn't support the Windows edition that's installed on the client.
  • The KMS host key doesn't match the product that you're activating (for example, trying to use a Windows Server 2016 KMS key to activate a Windows Server 2022 client).
  • You migrate the client from an on-premises environment that uses a different KMS infrastructure.

Resolution

To resolve this issue, make sure your KMS clients connect to the correct hosts. This factor is important if you're using specific KMS hosts to activate specific applications or operating systems.

To get the best results from these procedures, you should be familiar with the slmgr script.

  1. Open an administrative Command Prompt window on the client.

  2. To clear any existing KMS host setting, run the following command:

    cscript c:\windows\system32\slmgr.vbs /ckms
    
  3. To specify a KMS host for activation, run the following command:

    cscript c:\windows\system32\slmgr.vbs /skms <KMSHost_fqdn>:<KMSHost_Port>
    

    [!NOTE]

    • In this command, <KMSHost_fqdn> represents the fully qualified domain name (FQDN) of the KMS host, and <KMSHost_Port> represents the port that the KMS host uses.
    • To activate an Azure VM by using the Azure KMS service, use azkms.core.windows.net for <KMSHost_fqdn>, and use 1688 for <KMSHost_Port.
  4. To try again to activate, run the following command:

    cscript c:\windows\system32\slmgr.vbs /ato
    

References

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
- ✅ Supported versions of Azure Virtual Machine - ✅ Supported versions of Windows Client - ✅ Supported versions of Windows Server · Source date 05/29/2026
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。