Start / Stop / Enable / Disable Terminal services from command line

转载 2012年03月29日 11:51:03


http://www.windows-commandline.com/2010/10/start-terminal-services-command-line.html


How to start Terminal Services from command line?

We can start Terminal Services from command line 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.

Thishappens when Terminal Services is disabled through registry hack. Youcan 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

Youneed to reboot the computer for the changes to take effect. Afterreboot terminal services starts automatically or you can start theservice using net start command as mentioned above.

How to stop Terminal Services from command line?

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 from command line?

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 termninal services could be possible bykilling the svchost process that runs the terminal services.We can usetasklist and taskkill commands for this.

First get the process id of the terminal services process

 tasklist /svc | findstr /C:TermService

Checkif Terminal sevices is the only service running in this svchost. If thesvchost is shared with other services then you can stop readingfurther. Restarting terminal services is not possible on your machine.

On my machine 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 theprocess as it stops the other service also. (Note that DcomLaunch is anessential service on the system and killing it can even shutdown thesystem)


In the case of svchost not being sharedwith any other service you can go ahead and kill TermService process bythe following command.


taskkill /F /PID  process_id  


How to disable Terminal Services from command line?

We can run the below command to disable terminal services.

sc config TermService start= disabled

How to enable Terminal Services from command line?

sc config TermService start= auto

(or)

sc config TermService start= demand


相关文章推荐

shell bash script to start and stop named services

#!/bin/bash function docmd() { #echo 'func',"$1","$2" if [ "$1" = "nginx" ]; then ...

How can I get my public IP address from the command line, if I am behind a router?

24down voteaccepted Assuming your system has 2 ethernet devices, eth0 and eth1 and eth0 is con...
  • aqzwss
  • aqzwss
  • 2016年03月16日 12:24
  • 391

How to use FTP from the command line.

How to use FTP from the command line. FTP (File Transfer Protocol) allows you to transfer files b...

OpenSSL: Generating an RSA Key From the Command Line

原yy OpenSSL: Generating an RSA Key From the Command Line JAN 27TH, 2012 ♦ POSTED BY FRANK RI...

Export Xellerate configuration objects to XML files from the command-line

Export.javapackage com.zeroinllc.xellerate.utils; import java.util.*; import java.io.*; import ...

Run iOS Simulator from the Command Line (runsim)

Use the following script to install app in simulator. Just put the script under the MyApp.app direct...

How to monitor Nginx web server from the command line in real time

Once Nginx web server is up and running in a production environment, you will want to monitor its ...
  • xluren
  • xluren
  • 2014年10月15日 21:58
  • 963

Installing packages into Canopy User Python from the OS command line

参考网址:https://support.enthought.com/hc/en-us/articles/204469690-Installing-packages-into-Canopy-User-...
  • y999666
  • y999666
  • 2016年06月20日 21:42
  • 637
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Start / Stop / Enable / Disable Terminal services from command line
举报原因:
原因补充:

(最多只允许输入30个字)