How do I enable services on a Windows computer via a command line?
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Popsicle Puzzles
--
Chapters
00:00 How Do I Enable Services On A Windows Computer Via A Command Line?
00:35 Accepted Answer Score 44
01:37 Answer 2 Score 4
02:13 Thank you
--
Full question
https://superuser.com/questions/175077/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows7 #commandline #services
#avk47
ACCEPTED ANSWER
Score 44
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.
ANSWER 2
Score 4
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