Remote Desktop Services stopping

We can start Terminal Services by running the command given below.

net start TermService

If the service is already running you will get the message ‘The requested service has already been started.‘
Sometimes you may get an error that the service could not be started.

C:\>net start termservice The Terminal Services service is starting. The Terminal Services service could not be started. The service did not report an error. More help is available by typing NET HELPMSG 3534.

This happens when Terminal Services is disabled through registry hack. You can fix this by running the below registry change command.

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v TSEnabled /t REG_DWORD /d 1 /f

You need to reboot the computer for the changes to take effect. After reboot terminal services starts automatically or you can start the service using net start command as mentioned above.

How to stop Terminal Services?

Terminal Services can’t be stopped like other services.  You get the below error when you attempt the same.

C:\>net stop termservice The requested pause or stop is not valid for this service.

How to restart Terminal services?

Since Terminal Services can’t be stopped there is no straightforward way we can do this. Microsoft says this is by design. But in some cases restarting terminal services could be possible by killing the svchost process that runs the terminal services.We can use tasklist and taskkill commands for this.

First get the process id of the terminal services process

 tasklist /svc | findstr /C:TermService

Check if Terminal services is the only service running in this svchost. If the svchost is shared with other services then you can stop reading further. Restarting terminal services is not possible on your machine.

On my system I have got the following output.

C:\>tasklist /svc | findstr /C:TermService svchost.exe                 1708 DcomLaunch, TermService C:\> As you can see DcomLaunch and TermServiceboth share the same svchost process. In this case I can't kill the process as it stops the other service also. [Note that DcomLaunch is an essential service on the system and killing it can even shutdown the system] In the case of svchost not being shared with any other service you can go ahead and kill TermService process by the following command. taskkill /F /PID  process_id

How to disable Terminal Services?

We can run the below command to disable terminal services.

sc config TermService start= disabled

How to enable Terminal Services?

sc config TermService start= auto

[or]

sc config TermService start= demand

Sometimes as an IT Support administrator you may need to kill a service which is stuck at stopping in order to avoid having to reboot a server in the middle of the day.

Here’s what you need to do:

Step 1. Find out the Service Name

To do this, go in to services and double click on the service which has stuck.  Make a note of the “Service Name”.

Step 2. Find out the PID of the service

Open an elevated command prompt and type in:

sc queryex servicename

[where servicename is the name of the service you obtained from Step 1.]

Make note of the PID

Step 3. Kill the PID

From the same command prompt type in:

taskkill /f /pid [PID]

Where [PID] is the service number.

If it is successful you should receive the following message:

SUCCESS: The process with PID XXXX has been terminated.

Be careful of what you are killing though.  If you kill a critical windows service you may end up forcing the machine to reboot on it own.

Note: By forcing a service to stop you can also use these instructions to Kill a Windows Service which is stuck at starting as well.  This will allow you to restart the service.

Video Tutorial – How to Kill A Service which is Stuck at Stopping

[Total: 447 Average: 4.9]

Hi

I guess all of us met the phenomenon when a service refuses to stop and stuck on “Stopping” status.

well, there is a remedy to this by following this short procedure:

1. Identify the PID of the rogue service. open cmd and type: sc queryex

you will receive a long list of available services. you can also type sc queryex > c:\ServiceList.txt to send the output to a text file.

2. search the list of services for the problematic service:

SERVICE_NAME: Spooler DISPLAY_NAME: Print Spooler TYPE               : 110  WIN32_OWN_PROCESS [interactive]

STATE              : 3  STOP_PENDING

  • Article
  • 09/24/2021
  • 2 minutes to read

This article provides a solution to an issue where you can't restart the Remote Desktop Services [Terminal Services] if Keep-Alive is enabled.

Applies to:   Windows Server 2012 R2
Original KB number:   2507353

Symptoms

If the RDP Keep-Alive feature is enabled on a Windows Server 2008 [or Windows Server 2008 R2] server, manually stopping the Remote Desktop Services service [Windows Server 2008 R2] or Terminal Services service [Windows Server 2008] will leave the server in an unstable state: restarting the service won't re-enable RDP functionality, and the server will hang during shutdown.

Cause

The keep-alive thread is started by the Remote Desktop Services [Terminal Services] service if Keep-Alive is enabled, however it runs in Kernel mode and therefore can't be ended automatically when the service stops.

Resolution

Don't attempt to stop or restart the Remote Desktop Services [Terminal Services] service if the RDP keep-alive mechanism is enabled.

When Keep-Alive is enabled and the Remote Desktop Services [Terminal Services] service is stopped, its svchost.exe process will remain in the Task list, even though the service is reported to have stopped correctly. When the service is started again, a new svchost.exe will be started however the server won't accept incoming RDP connections because of inconsistency in the TermDD driver state.

The Keep-Alive feature can be enabled by Group Policy:

  • Windows Server 2008 R2

    Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Connections

    Configure Keep-Alive Connection Interval

  • Windows Server 2008

    Computer Configuration\Administrative Templates\Windows Components\Terminal Services\Terminal Server\Connections

    Configure Keep-Alive Connection Interval

To configure directly in the registry:

Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server] "KeepAliveInterval"=dword:00000001 "KeepAliveEnable"=dword:00000001

  • Hello Everybody!

    I tried to restart Remote Desktop service on my Windows 10, and strange error occurs:

    "Event 20501: Remote Desktop Services failed to shutdown within the time allocated"

    Remote Desktop service still stay in state = stopping, and TaskManager shows PID=340 for TermService.

    How to restart RDS without restart a PC ?

Answers

  • First run tasklist from a command prompt to find what PID the service is using.

    Then run taskkill /PID "PIDNumber"

    Please Mark This As Answer if it solved your issue Please Vote This As Helpful if it helps to solve your issue Sebastian Norén

    • Proposed as answer by Amy Wang_ Tuesday, June 14, 2016 12:34 PM
    • Marked as answer by SergeyU100 Tuesday, June 14, 2016 12:36 PM

Video liên quan

Chủ Đề