How to Manage Windows Services via Command Line

I always attractiveness for practiced medians to seize care of contraption assignments without disclaiming the terminal, also as speedily as I am grossing gain service of of Windows. On Windows, handles sprinted in the background to grasp ago the contraption and also apps operating calmly. Instead of opening the Solutions Employer, I advice to seize care of the Windows Solutions via the command line. In this guide, we’ll study these tactics and also consultation how you can seize care of Windows handles right from the terminal.
Table of Fabrics
- 1. Oversaw Windows Solutions using sc.exe
- 2. Oversaw Windows Solutions By means of Net Command
- 3. Oversaw Windows Solutions using PowerShell Cmdlets
- 4. Automate Solution Surveillance Job
1. Oversaw Windows Solutions using sc.exe
sc.exe is a prefabricated-in command-line tool for taking care of Windows handles. It makes it viable for you configure, query, and also manage handles nondiscriminatory from the terminal. By means of sc.exe, you recover full manage over Windows handles without demanding the visual Solutions Employer.
Weighing remedy prestiges using sc
We can usage the sc query serviceName
command to investigate the prestiges of a capricious remedy. For example, we sprinted the sc query MySQL80
command to recover niceties about the MySQL80 remedy, incorporating its say:

Presently, MySQL is not sprinting on our machine.
Jumpstarting a remedy using sc
To prelude a capricious remedy grossing gain service of of sc.exe, we can usage the sc start ServiceName
command. For example, we sprinted sc start MySQL80
to prelude the MySQL80 remedy. To confirm if the remedy has introduced efficiently, we can investigate its prestiges grossing gain service of of the sc query MySQL80
command:

Doning grasp a remedy using sc
You can guard against a remedy to cost-free upward contraption sources. For example, the command sc stop MySQL80
protects against MySQL, which can be proved grossing gain service of of the sc query MySQL80
command:

Earning a brand-newfangled remedy using sc
We can collect a brand-newfangled remedy grossing gain service of of the sc create
command. This requires epitomizing the remedy moniker, executable trail, and also start-up kind. For example, to collect a brand-newfangled remedy labelled “mte” that will most distinctly prelude immediately at boot, kind:
sc create mte binPath= "C:UsersHPDesktopExamplesService.exe" start= auto

Overhauling a remedy using sc
We can usage the sc config
command to configure an existing remedy. For example, to readjust the start-up kind to handbook, sprinted the command:
sc config serviceName start= demand

Separating a remedy using sc
Once a remedy is most distinctly no longer necessary, we can retrieve rid of it totally from Windows grossing gain service of of the command:
sc delete srviceName

2. Oversaw Windows Solutions By means of Net Command
The net
command in Windows makes it viable for us to seize care of handles from the command line. It makes it viable for audiences to prelude, guard against, pause, resume, and also query handles without grossing gain service of of the visual Solutions Employer.
Jumpstarting and also shunning remedy using net command
We can prelude or guard against Windows handles using the net start serviceName
and also net stop serviceName
commands, respectively:

Doning grasp and also returning to handles using net command
Some Windows handles stabilize pausing and also returning to instead of a finalize guard against. In that vessel, we can usage the net pause ServiceName
and also net continue ServiceName
commands, respectively:

Weighing remedy prestiges using net command
The net command itself executes not administer a linear way to investigate the prestiges of a capricious remedy, however we can usage it along using the findstr
command to filter the results. For example, to investigate if the marked remedy is sprinting, kind:
net start | findstr "ServiceName"

If the marked remedy is sprinting, the command rejoinders its moniker; or else, there is most distinctly no result.
Oversaw handles from an additional venue using net command
We can usage the net command to seize care of handles on confidential computers by epitomizing the computer system moniker. For example, the net start ServiceName /S RemotePC
and also net stop ServiceName /S RemotePC
commands are sold to prelude or guard against handles on a confidential computer system.
3. Oversaw Windows Solutions using PowerShell Cmdlets
PowerShell deals more graced manage over Windows handles using prefabricated-in cmdlets pick Render usage-Solution, Start-Solution, Put off-Solution, and also Restart-Solution. These cmdlets enable audiences to investigate the prestiges of a remedy, prelude or guard against it, and also also restart it as speedily as necessary.
PowerShell cmdlets administer outlined result, incorporating remedy prestiges, sport moniker, and also dependent handles. These cmdlets enable scripting and also automation, grossing it useful for taking care of multiple handles ideally.
PowerShell’s convenience and also effective amenities administer it the favored tool for administrators taking care of Windows handles.
Acquiring remedy prestiges using cmdlets
We can usage the Get-Service -Name ServiceName
cmdlet to recover the niceties about the marked remedy. For example, the consequent command rejoinders the prestiges of the MySQL80 remedy, showing whether it is sprinting or shunned:
Get-Service -Name MySQL80

Quizing handles using PowerShell cmdlets
We can usage the Get-Service
command to query the handles based on capricious criterions. For example, we can recover with one voice presently sprinting handles grossing gain service of of the command:
Get-Service | Where-Object {$_.Status -eq 'Running'}

Jumpstarting and also Doning grasp Solutions using PowerShell cmdlets
We can prelude or guard against a capricious remedy grossing gain service of of the Start-Service
and also Stop-Service
cmdlets respectively. For example, we usage PowerShell commands to prelude, guard against, and also investigate the prestiges of the MySQL80 remedy:
Start-Service -Name MySQL80
Stop-Service -Name MySQL80
Get-Service -Name MySQL80

Matching remedy start-up kind using PowerShell cmdlets
PowerShell cmdlets enable us to modernize the remedy start-up kind. For example, we can sprinted the consequent cmdlets to configure a remedy to prelude immediately using the contraption, need handbook start-up, or be maimed, respectively:
Set-Service -Name ServiceName -StartupType Automatic
Set-Service -Name ServiceName -StartupType Manual
Set-Service -Name ServiceName -StartupType Disabled
These cmdlets help administrators seize care of remedy assignments ideally, which ensures that fruitful handles prelude as necessary while inhibiting nonessential ones from sprinting.
Taking care of confidential handles using cmdlets
PowerShell in a comparable way makes it viable for taking care of handles on confidential computers by epitomizing the tags of the confidential computers. For example, the Get-Service -Name ServiceName -ComputerName RemotePC
command recovers the prestiges of a capricious remedy sprinting on a confidential computer system labelled RemotePC, permitting administrators to sport handles from an additional venue.
Alternatively, the Restart-Service -Name ServiceName -ComputerName serviceName
command attempts to restart the marked remedy on a confidential computer system. It ensures that the remedy restarts without demanding linear lessen of access to the machine. However, confidential remedy management requires opportune assents and also PowerShell remoting to be made it viable for.
4. Automate Solution Surveillance Job
PowerShell manuscripts enable automating remedy management, grossing it less complicated to sport and also manage Windows handles without handbook intervention. We can collect a manuscript that repeatedly checks the prestiges of a capricious remedy and also restarts it if it protects against suddenly.
For example, the consequent manuscript checks whether the MySQL80 remedy is sprinting and also restarts it if it is shunned:
$serviceName = "MySQL80"
$service = Get-Service -Name $serviceName
if ($service.Status -ne "Running") {
Restart-Service -Name $serviceName -Force
Write-Output "$serviceName was stopped and has been restarted."
} else {
Write-Output "$serviceName is already running."
}
By default, Windows bans sprinting manuscripts. To enable execution, initially, perform the command:
Set-ExecutionPolicy RemoteSigned

Now navigate to the manuscript liberty and also sprinted the .serviceScript.ps1
command to sprinted the manuscript:

Taking care of Windows handles from the command line provides you finalize manage without relying on the visual Solutions Employer. Whether you usage sc.exe, net, or PowerShell cmdlets, each perspective deals practiced medians to prelude, guard against, and also configure handles.
PowerShell’s scripting capacities administer automation straightforward, permitting you to sport and also seize care of handles flawlessly. By acknowledgment these contraptions, you can troubleshoot top priorities, maximize contraption capability, and also ensure critical handles sprinted calmly.
For more medians to maximize your Windows contraption and also troubleshoot ordinary top priorities, investigate out these directs on squaring Windows annoyances and also grossing ideal usage of your PC for much more outlined capability.