Table of Contents
Use sc.exe in Command Prompt or PowerShell, or PowerShell’s service cmdlets, to inspect and control Windows services. Start with a query, identify the correct service name, and make only the change you intend. Stopping a database or dependent system service can interrupt applications and users.
Identify the service and permissions
Open an administrator terminal for operations that require it. A service’s short Name can differ from its friendly DisplayName. This PowerShell command lists both:
Get-Service | Select-Object Name, DisplayName, StatusThe examples use MySQL80, which exists only if that MySQL service was installed with that name. Replace it with a service you are authorized to manage. Research an unfamiliar Windows service with the Windows Service Lookup before changing it.
1. Inspect and control services with sc.exe
Write sc.exe explicitly. In Windows PowerShell, sc can be an alias for Set-Content, which writes file content instead of managing services.
Query status and configuration
sc.exe query MySQL80
sc.exe qc MySQL80
The first command reports state; the second shows configuration, including startup and executable information. A pending state means the operation has not finished. Query again before concluding that a start or stop succeeded.
Start or stop—choose one operation
To start the example service:
sc.exe start MySQL80
sc.exe query MySQL80
To stop it during an intended maintenance operation:
sc.exe stop MySQL80
sc.exe query MySQL80
Do not stop an unfamiliar service merely to “free resources.” Check dependencies and application impact first. A service must support the requested control.
Create a service only for a service-compatible executable
An ordinary desktop program does not become a Windows service just because it is registered. Prefer the software vendor’s installer. For a service executable you developed or are explicitly instructed to register, the syntax includes a space after each option’s equals sign.
This example assumes a real service-compatible binary already exists at the illustrated path; it does not create that file:
sc.exe create DemoService binPath= C:ServiceDemoService.exe start= demand
A path containing spaces also needs correct quoting in the stored service command line. Follow the executable’s installation documentation, use an appropriate service account, and inspect the result with sc.exe qc DemoService. Do not store a production service in a user’s desktop folder.
Change startup type
For the same disposable example, the following selects manual startup:
sc.exe config DemoService start= demand
auto means automatic startup; disabled prevents starting until reconfigured. Changing startup type is different from immediately starting or stopping the service. Record the previous configuration first.
Remove a service registration
Use the vendor’s uninstaller when available. For a test service you created and no longer need, stop it first, then remove its registration:
sc.exe delete DemoService
This is not a general cleanup command. It does not uninstall the program or delete its executable, and a running service or open handle can delay removal. See Microsoft’s SC configuration documentation.
2. Use net for simple local controls
These are alternatives, not a sequence to run blindly:
net start MySQL80
net stop MySQL80
For a service that supports pausing, use net pause ServiceName and net continue ServiceName, replacing the placeholder.

net start without a service lists running services. Filtering that display with findstr can be convenient, but a missing text match does not reliably distinguish “stopped,” “not installed,” or a different display name. Use sc.exe query or Get-Service for a specific status check.

net start ServiceName /S RemotePC is not a valid general remote-service command. SC supports a remote server argument, for example sc.exe \RemotePC query MySQL80, subject to permissions and remote Service Control Manager connectivity. Do not open broad firewall access just to make an example work.
3. Use PowerShell service objects
Get-Service -Name MySQL80
Get-Service | Where-Object { $_.Status -eq 'Running' }

Start a service and verify it with separate commands:
Start-Service -Name MySQL80 -ErrorAction Stop
Get-Service -Name MySQL80
Use Stop-Service or Restart-Service only when that operation is intended. To change startup type, use Set-Service -Name MySQL80 -StartupType Manual, with the appropriate service and chosen type.
Manage an authorized remote computer
For an environment where PowerShell remoting is already configured and permitted:
Invoke-Command -ComputerName RemotePC -ScriptBlock {
Get-Service -Name MySQL80
}Replace RemotePC and the service name. Do not add an unsupported ComputerName parameter to Restart-Service. A deliberate remote restart can run inside the script block, followed by a status check, but it requires the same authorization and maintenance planning as a local restart.
4. Automate only after testing the operation
A script that checks once is not continuous monitoring. Before adding automatic recovery, decide which states should trigger action, how to log errors, and how to avoid a restart loop. A service may be intentionally stopped for maintenance.

Inspect Get-ExecutionPolicy -List if a reviewed script is blocked. Do not change machine-wide policy or bypass organization controls just to run downloaded code. Execution policy is not a substitute for reviewing a script.

Run a script in the current folder using .serviceScript.ps1, after reviewing its contents and prerequisites. Use -ErrorAction Stop and error handling for operations whose failure must halt a workflow; print a success message only after verification.
The PowerShell Command Lookup and Microsoft’s service-management examples provide further command context. Verify the installed PowerShell version and service state before adapting an example to production.
Reader Comments 0
Sign in with email or Google to join the discussion.