How do I enable services on a Windows computer via a command line?

23

11

On my Sony Viao pcg-811124 laptop with Windows 7, I disabled all non-Windows services through msconfig. When I restarted my laptop, it booted up, but I cannot view the screen, even in safe mode. I may have disabled a driver, but now I have no way of knowing which one.

So, not only do I not know which services I disable and need to enable, I can't seem to even enable the services I know that I have (for example, JungleDisk). When tried to restart it via the command line, I got prompted that I could not restart this service because it had been disabled.

How do I get my services enabled again?

frosty

Posted 2010-08-12T09:59:36.757

Reputation: 363

Answers

35

I believe the command you are looking for is:

sc config servicenamehere start= auto

You'll need to know the name of the service though - to view this from the command line, try this command - this will show all services:

sc query type= service state= all

If you want to see only stopped services, run this command:

sc query type= service state= inactive

The list of services output by the query can be quite long. You may filter it by using findstr (see post here) . For example

sc query type= service state= all | findstr "ssh"

Will select the output lines of the services list that contain the string "ssh"

Note: For some services you may need also administrator privileges, you will notice it on getting the message Access is denied after executing the sc command. In that case open the Command Prompt (Admin) by pressing 'Windows + X' keys.

emtunc

Posted 2010-08-12T09:59:36.757

Reputation: 613

2No it's not, at least not in Windows 10. – Joel G Mathew – 2017-03-16T17:31:32.187

6NOTE: the space after the = is an essential part of the syntax. – Nathan – 2014-06-12T01:03:37.840

1

You can use PowerShell! (To start it, type powershell at a normal command prompt.)

The Get-Service cmdlet gets a list of services, which you can filter by any property. For example, this gets a list of disabled services:

Get-Service | ? {$_.StartType -eq 'Disabled'}

The Set-Service cmdlet can set several properties of a given service, including the startup type. For example, this sets the lanmanserver service to start automatically:

Set-Service 'lanmanserver' -StartupType Automatic

To make all currently disabled services start automatically, use this command:

Get-Service | ? {$_.StartType -eq 'Disabled'} | Set-Service -StartupType Automatic

Ben N

Posted 2010-08-12T09:59:36.757

Reputation: 32 973