远程桌面服务在 Azure VM 上不启动Remote Desktop Services isn't starting on an Azure VM

本文介绍如何排查连接到 Azure 虚拟机 (VM) 时远程桌面服务 (TermService) 不启动或无法启动的问题。This article describes how to troubleshoot issues when you connect to an Azure virtual machine (VM) and Remote Desktop Services, or TermService, isn't starting or fails to start.

Note

Azure 提供两种不同的部署模型用于创建和处理资源:Azure 资源管理器部署模型和经典部署模型Azure has two different deployment models to create and work with resources: Azure Resource Manager and classic. 本文介绍资源管理器部署模型的用法。This article describes using the Resource Manager deployment model. 建议为新部署使用此模型,而不是使用经典部署模型。We recommend that you use this model for new deployments instead of the classic deployment model.

症状Symptoms

尝试连接到 VM 时遇到以下情况:When you try to connect to a VM, you experience the following scenarios:

  • VM 屏幕截图显示操作系统已满载,并正在等待凭据。The VM screenshot shows the operating system is fully loaded and waiting for credentials.

    VM 状态的屏幕截图

  • 在使用事件查看器远程查看 VM 中的事件日志时,You remotely view the event logs in the VM by using Event Viewer. 你发现远程桌面服务 (TermService) 未启动或无法启动。You see that Remote Desktop Services, TermService, isn't starting or fails to start. 下面是日志示例:The following log is a sample:

    日志名称: 系统Log Name: System
    : 服务控制管理器Source: Service Control Manager
    日期: 2017 年 12 月 16 日上午 11:19:36Date: 12/16/2017 11:19:36 AM
    事件 ID: 7022Event ID: 7022
    任务类别:无Task Category: None
    级别: 错误Level: Error
    关键字: 经典Keywords: Classic
    用户: 不适用User: N/A
    计算机: vm.contoso.comComputer: vm.contoso.com
    说明:远程桌面服务在启动时挂起。Description: The Remote Desktop Services service hung on starting.

原因Cause

之所以发生此问题,是因为远程桌面服务未在 VM 上运行。This problem occurs because Remote Desktop Services isn't running on the VM. 未运行的原因取决于以下情况:The cause can depend on the following scenarios:

  • TermService 服务设置为“已禁用”。 The TermService service is set to Disabled.
  • TermService 服务崩溃或未响应。The TermService service is crashing or not responding.
  • 错误的配置导致 TermService 不启动。The TermService is not starting because of to an incorrect configuration.

解决方案Solution

若要排查此问题,可通过将 VM 的 OS 磁盘附加到恢复 VM 来修复 VM 脱机To troubleshoot this issue, repair the VM offline by attaching the OS disk of the VM to a recovery VM.

修复 VM 脱机Repair the VM offline

将 OS 磁盘附加到恢复 VMAttach the OS disk to a recovery VM

  1. 将 OS 磁盘附加到恢复 VMAttach the OS disk to a recovery VM.

  2. 开始与恢复 VM 建立远程桌面连接。Start a Remote Desktop connection to the recovery VM. 确保附加的磁盘在磁盘管理控制台中标记为“联机”。 Make sure that the attached disk is flagged as Online in the Disk Management console. 请注意分配给附加的 OS 磁盘的驱动器号。Note the drive letter that's assigned to the attached OS disk.

  3. 打开权限提升的命令提示符实例(“以管理员身份运行”)。 Open an elevated command prompt instance (Run as administrator). 然后运行以下脚本。Then run the following script. 假设分配给附加的 OS 磁盘的驱动器号为 F。请将它替换为 VM 中的相应值。We assume that the drive letter that's assigned to the attached OS disk is F. Replace it with the appropriate value in your VM.

    reg load HKLM\BROKENSYSTEM F:\windows\system32\config\SYSTEM.hiv
    
    REM Set default values back on the broken service 
    reg add "HKLM\BROKENSYSTEM\ControlSet001\services\TermService" /v start /t REG_DWORD /d 3 /f
    reg add "HKLM\BROKENSYSTEM\ControlSet001\services\TermService" /v ObjectName /t REG_SZ /d "NT Authority\NetworkService" /f
    reg add "HKLM\BROKENSYSTEM\ControlSet001\services\TermService" /v type /t REG_DWORD /d 16 /f
    reg add "HKLM\BROKENSYSTEM\ControlSet002\services\TermService" /v start /t REG_DWORD /d 3 /f
    reg add "HKLM\BROKENSYSTEM\ControlSet002\services\TermService" /v ObjectName /t REG_SZ /d "NT Authority\NetworkService" /f
    reg add "HKLM\BROKENSYSTEM\ControlSet002\services\TermService" /v type /t REG_DWORD /d 16 /f
    
  4. 分离 OS 磁盘并重新创建 VMDetach the OS disk and recreate the VM. 然后检查是否解决了问题。Then check whether the issue is resolved.

需要帮助?Need help? 联系支持人员Contact support

如果仍需帮助,请联系支持人员解决问题。If you still need help, contact support to get your issue resolved.