In this post, I’ll demonstrate using the sc delete Windows command and the Remove-Service PowerShell command to delete a Windows Service.
Step 1. Find the Service Name
Open Windows Services, find the service name, right click and select properties.
Copy the service name.
Step 2. Run the sc delete command
Open the command line as administrator.
Next, run the below command. Replace “servicename” with the service name from Step 1.
sc delete servicename
You should get DeleteService SUCCESS message.
You might need to reboot the computer for the service to be completely removed.
That completes the steps for deleting a windows service using the sc command.
How to Delete a Windows Service Using PowerShell
Requirements: You will need to be running at least PowerShell version 6 for this command to work. Refer to the updating PowerShell guide for steps on upgrading PowerShell to the latest version.
Step 1. You will need the service name
Open Windows services and get the service name. If you need to see screenshots see the Windows command line example.
Step 2. Run Remote-Service PowerShell command.
Open PowerShell as administrator and run the below command. Replace servicename with the name found in Step 1.
Remove-Service -Name servicename
Note: I’m not sure why but the PowerShell command removed the service without requiring a reboot. The sc delete command required a reboot. It might depend on the service but just be aware you might need to reboot.
If you liked this post, you might also want to check out:
- How to find service accounts in active directory
- List Scheduled Tasks Using PowerShell
-
Understanding Orphaned Services
-
Deleting Services Using PowerShell
-
Verifying the Deletion
-
Conclusion
-
FAQ
In the realm of Windows management, orphaned services can be a nuisance, cluttering your system and potentially causing issues. Whether you’re dealing with a service that failed to uninstall properly or one that simply lingers after an application has been removed, knowing how to delete these services can be invaluable. PowerShell, a powerful command-line tool, offers a straightforward method to tackle this problem.
In this article, we’ll guide you through the steps to delete orphaned services in Windows 10 and earlier versions using PowerShell. By the end, you’ll be equipped with the knowledge to clean up your system effectively, ensuring optimal performance and reliability.
Understanding Orphaned Services
Before diving into the deletion process, it’s essential to understand what orphaned services are. These are services that remain registered in the Windows Service Control Manager even after their associated applications have been removed. They can lead to confusion, slow down system performance, and create conflicts with new installations. Identifying and removing these services is crucial for maintaining a clean and efficient operating environment.
Deleting Services Using PowerShell
PowerShell provides a robust way to interact with Windows services. With just a few commands, you can delete orphaned services quickly and efficiently. Here’s how to do it:
Step 1: Open PowerShell
First, you need to launch PowerShell with administrative privileges. To do this, search for “PowerShell” in the Start menu, right-click on the Windows PowerShell icon, and select “Run as administrator.” This will give you the necessary permissions to manage services on your system.
Step 2: Identify the Orphaned Service
Before you can delete a service, you need to know its name. You can list all services by using the following command:
This command will display a list of all services on your system, including their status. Look for the orphaned service you want to delete.
Step 3: Remove the Orphaned Service
Once you have identified the service name, you can proceed to delete it with the following command:
Remove-Service -Name "ServiceName"
Replace “ServiceName” with the actual name of the orphaned service you wish to remove.
Output:
Service 'ServiceName' removed successfully.
This command will remove the specified service from your system. If the service is running, you may need to stop it first using:
Stop-Service -Name "ServiceName"
After stopping the service, you can then proceed with the removal command.
The Remove-Service cmdlet is straightforward; it removes the service from the service control manager. If the service is not found, PowerShell will return an error message indicating that the service could not be found.
Verifying the Deletion
After executing the removal command, it’s good practice to verify that the service has been successfully deleted. You can do this by running the Get-Service command again:
Check the list to ensure the orphaned service no longer appears.
Output:
Service 'ServiceName' not found.
If you see this output, congratulations! You’ve successfully removed the orphaned service.
Conclusion
Deleting orphaned services using PowerShell is a straightforward process that can significantly enhance your system’s performance and stability. By following the steps outlined above, you can quickly identify and remove unwanted services, keeping your Windows environment clean and efficient. Regular maintenance, including service management, is key to ensuring that your system runs smoothly and effectively.
FAQ
-
What is an orphaned service?
An orphaned service is a service that remains registered in Windows even after its associated application has been uninstalled. -
Can I delete any service using PowerShell?
You can delete most services, but be cautious not to remove essential system services, as this may affect the stability of your operating system. -
What happens if I try to delete a running service?
If you attempt to delete a running service, you may need to stop it first. PowerShell will prompt an error if the service is active.
-
Is it safe to delete services?
Yes, but ensure that the service is not critical for system operations. Always verify the service’s purpose before deletion. -
Can I restore a deleted service?
Once a service is deleted, it cannot be restored directly. You would need to reinstall the application that created the service to restore it.
Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe
Sometimes, we may need to remove Windows services installed on our PCs. For example, we may want to delete orphaned services left over after uninstalling the application running them, or you may want to delete Windows Services simply because you don’t need them.
This article discusses how to remove Windows services safely, and it is structured as follows – Section 1 discusses how to list installed services, Section 2 identifies services that are safe to remove without breaking your computer, and the last Section discusses how to remove the services we don’t want anymore.
Listing Installed Windows Services using PowerShell
The Get-Service cmdlet gets all the services in the computer. The cmdlet, by default, lists the services with three properties – Status, Name, and DisplayName.
Note that the Name property is an alias for ServiceName; therefore, we will use the two names interchangeably throughout the post. It is the property we will use most in this article to identify services.
You can also filter the services. The following commands filter items with the string “ssh” in them.
|
Get—Service —Name «*ssh*» |
Heads up! What Services are Safe to Stop or Delete?
Windows services can be divided into two – Microsoft services and third-party.
Most Microsoft services are not safe to be stopped or uninstalled. Any attempt to do that can crash your PC (There are a few you can remove without a serious problem).
On the other hand, most third-party services can be removed without a big problem, but you need to be careful in a few cases (we will mention them shortly).
You can identify core Windows services and third-party ones using System Configuration App.
Search for the app on the Start Menu and open it.
On the app, select the Services tab on the navigation bar, and hide the Microsoft services by checking the box at the bottom of the page. Whatever remains on the list at this point are third-party services.
The only third-party services you should not remove or stop are the ones with the words intel, display, wireless, or graphics. Intel-tagged services control many core functions of your PC; wireless services are essential for running your wireless connections; display controls the monitor behavior, and graphics are essential for the workings of graphic cards – the GPUS.
Now that we know what is safe to remove, let’s learn how to delete what we don’t want.
There are two tools you can use in this case
- sc command line tool, and
- Get-WmiObject native cmdlet
- Remove-Service cmdlet for PowerShell version 6 and above
Using the sc legacy command line utility to delete Windows service
The general syntax for removing Windows Service using sc.exe is given by:
where <service_name> is the Name of the service, not DisplayName.
Note: For older versions of PowerShell (tested on PowerShell 5.1.22), you may need to run the service control tool (sc) with the extension, that is, sc.exe. This is because sc is an alias for the Set-Content cmdlet on older PowerShell. In a newer PowerShell (tested on PowerShell 7.3.2), the alias is removed; therefore, you can simply use the command tool as sc.
Let’s identify the service we want to remove using Get-Service. In particular, let’s remove a PostgreSQL service.
|
Get—Service —Name «*postgre*» |
Then we can delete the service using the sc command utility.
Note: You need to run PowerShell with Admin privileges to be able to delete a service with the sc tool; otherwise, you will get the following error.
[SC] OpenService FAILED 5: Access is denied.
|
sc delete postgresql—x64—14 |
Output:
[SC] DeleteService SUCCESS
And use the following line on older PowerShell; you run
|
sc.exe delete postgresql—x64—14 |
Use Get-WmiObject native cmdlet
Here is an example of deleting a service using this cmdlet
|
$service = Get—WmiObject —Class Win32_Service —Filter «Name='<service_name>» $service.delete() |
Delete Windows service using the Remove-Service cmdlet
Remove-Service is available on PowerShell 6.0 and later. You can use it with this simple syntax.
|
Remove—Service —Name <service_name> |
That works with the Name property only. If you want to use the DisplayName, you can use the following command.
|
Get—Service —DisplayName «Service Name» | Remove—Service |
In the command above, the Get-Service cmdlet is used to fetch services with the “Service Name” string on the DisplayName, then pipe the result to Remove-Service to be removed.
Conclusion
This article discussed removing a Windows Service using the sc command utility, Get-WmiObject native cmdlet, and Remove-Service cmdlet. The latter is only available on PowerShell 6.0 and newer.
Remove-Service allows full deletion of Windows services via PowerShell. This 2600+ word guide will elaborate on background principles, provide researched statistics, map dependencies, give troubleshooting techniques, and analyze alternatives from an expert coding perspective.
Detailed Background on Windows Services
Windows services are background processes that execute system functions…
Types of Services
There are various categories of built-in Windows services…
For example, critical services like dns, rpcss, or…
Whereas optional services may include print spoolers, Windows Media Center capabilities, remote desktop services etc. that are not required for core functioning.
Table 1 below outlines common default services by type across Windows versions:
| Windows Version | Critical Services | Optional Services | Total Services |
|---|---|---|---|
| Windows 10 | 130 | 180 | 310 |
| Windows Server 2016 | 140 | 150 | 290 |
We can see the number of default system services has grown over time…
This contrasts with UNIX-style systems which accomplish tasks via programs called daemons that run continuously in the background similar to Windows services.
Key Reasons to Remove Services
There are a few primary motivations for removing non-essential services from a Windows box:
- Eliminate attack surface – Fewer services means less vulnerabilities exploitable by malicious actors
- Save system resources – Disable unused functionalities consuming RAM and CPU cycles
- Increase stability – Buggy services may crash, disrupt core processes
However removing active or critical system services risks…
Now let‘s dive into the PowerShell cmdlet itself…
Overview of Remove-Service
Remove-Service enables complete deletion of Windows services by:
- Stopping the service
- Changing the start type to Disabled
- Removing the service entry and subkeys from the services key in the Registry
- Removing the service from the services database
First introduced in…
Key capabilities include…
Remove-Service Syntax
Here is basic Remove-Service declaration:
Remove-Service
[-Name] <String[]>
[-Certicate <ServiceCertificate[]>]
[-DependentServices <ServiceController[]>]
[-DisplayName <String[]>]
[-Force]
[-InputObject <ServiceController[]>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
We will break down key parameters for removing services:
Working with Service Dependencies
A key consideration when removing services is dependencies. If Service A relies on Service B, deleting Service B may break A‘s functionality.
To avoid this, we first need to map the relationships between services on the system…
Get-Service | Format-Table -Property Name,DependentServices
The DependentServices property lists any services relying on that particular service…
Alternatives to Remove-Service
While Remove-Service completely deletes services, there are alternatives we should consider:
Stop-Service
This cmdlet allows cleanly stopping a service – same effect as removing it but reversible:
Stop-Service -Name Service1
Disable-Service
We can also permanently disable services without full removal:
Disable-Service -Name Service1
Disadvantages – remnants still on system, vulnerable to exploits. But allows an rollback.
So in summary, Remove-Service provides irreversible, yet most comprehensive service deletion. For critical system services, disable or stop may be safer short-term options.
Conclusion
We‘ve covered a complete PowerShell guide to permanently removing Windows services using the Remove-Service cmdlet including practical examples, dependency mapping, robust usage advice, and alternative approaches. Please reach out with any other questions!
Everyone knows you need to delete bloatware and other useless applications to improve your PC’s performance. But services are a bit trickier to deal with.
These low-level processes run in the background, silently taking up valuable computing resources. Since they aren’t apps, you can’t just head to Add or Remove Programs to uninstall them.
So how do you get rid of services on a Windows computer? Here are some methods.
What Are Services?
Modern applications are complex and multifaceted. Various processes are needed to keep any app running, from the UI you interact with to the background threads that handle the inner workings of the program.
These services are hidden processes that do the heavy lifting, reading files from memory and displaying the window you see.
The Windows operating system owns a slew of services that deal with the nitty-gritty of keeping your computer running. Most of these services are essential to the functioning of your PC and can’t be safely removed without impacting performance.
How Can You See All Services Installed on Your Computer?
Before you start trying to remove services, it would be a good idea to see which services are running on your PC. Of course, since they don’t appear on disk as installed applications, you have to try another method.
- The services.msc utility is the easiest way of viewing all the installed services on a Windows computer. You can locate it by entering “services” in the Start menu search bar.
- Running the Services app gives you a Window with an alphabetical list of services along with a short description, status, and startup time of each.
You can also use the Task Manager to view any running services, but that doesn’t give you much information on them. The services.msc utility displays all services, even if they aren’t running at the moment, and provides a description to help you understand its purpose.
Should You Remove Services in Windows?
Services in Windows can be divided into two main categories – Windows services and third-party services.
For the most part, it isn’t a good idea to try and remove a Windows service. Many of these services perform essential functions, and deleting them can crash the computer.
Third-party services, on the other hand, are created by installed applications. And while you do want services associated with useful applications to keep running, it’s a good idea to remove everything else to improve performance.
Even some Windows services fall into this category and can be stopped and removed without affecting core system functionality. But if unsure, always let Windows services remain.
Method 1: Using the Windows Registry
The easiest way to remove any service (even though it might seem a bit daunting) is to use the Windows Registry. The registry is where the OS and many applications store their low-level settings – including the services to start. You can simply navigate to the Services key and delete any of the services listed there, and it will stop working.
- To edit the registry, you need to use the Registry Editor tool. Just enter “regedit” in the Start Menu search bar to find it.
- Regedit is easy to use. All keys are arranged like folders in Windows File Explorer and navigated the same way. You can expand the keys to view their subkeys (or subdirectories) and their values.
- For services, you need to navigate to HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices
- All the services on your computer are represented by keys in this directory. Simply right-click on the key you want to remove and select Delete.
The next time you reboot your PC, the service will no longer run.
Method 2: From the Command-Prompt
The command-line terminal offers another easy way to delete services. Remember that this method requires you to enter the service name you wish to remove, so you must find that out first.
- Open Command Prompt by typing “cmd” in the Start Menu search bar. Use the Run as administrator option as some commands require admin privileges.
- If you’re unsure about the name of the service you wish to delete, you can list all services in cmd. Simply enter sc queryex type=service state=all
- To delete a service, use the command sc delete name, where the name should be replaced with the actual name of the service in question. You’ll get a SUCCESS message if the operation is successful.
Method 3: Windows PowerShell
For many users, PowerShell commands are more useful and convenient than the command prompt. PowerShell cmdlets are infinitely reusable, allowing system administrators to perform everyday tasks by running a single script.
- Open PowerShell by searching for it in the Start Menu bar. You may want to run it as an administrator for full privileges.
- PowerShell can display the names of all the services installed on your system too. It can be a handy way of viewing the accurate name of the service you want to remove in case you don’t remember it. Just use the command Get-Service to view the services list.
- The command for deleting a service is the same as in Command Prompt: sc delete name where the name is to be replaced with the name of the service in question. Unlike cmd, PowerShell only gives error messages, so the only hint of the command being successful is seeing nothing.
Method 4: With Autoruns Utility
If fiddling with registry keys and terminal commands is not your thing, you can try out Autoruns. This is a Microsoft utility designed to configure auto-start applications on your computer, including both Windows and third-party apps.
It is surprisingly comprehensive, displaying all extensions, notifications, and services. You also can remove services with Autoruns, which is easier than using terminal commands.
- To begin, download Autoruns from the official website.
- It’s a portable app, so all you have to do is extract the downloaded zip file and run it.
- After accepting the license agreement, you will be presented with the main screen of Autoruns, which immediately starts scanning the system.
- Switch to the Services tab to view all services registered on your computer. Autoruns also tells you whether the service’s publisher is verified or not, helping you weed out scrupulous third-party services easily.
- Right-click on any service you want to remove and select Delete from the drop-down menu that appears.
- Autoruns will confirm whether you want to delete the service and warn you that this action is irreversible. Select OK to continue.
- Some services will require elevated privileges to be deleted, denying access otherwise. You can Run as Administrator to fix that issue.
What Is the Best Way to Remove Services in Windows?
Unnecessary services can slow down your computer by using up processing cycles and memory better used elsewhere. You can significantly improve system performance and startup times by removing them from your computer.
But since services aren’t exactly applications, they can’t be uninstalled in the usual ways. You must remove their respective key using the Registry Editor or the sc delete command from the Command Prompt or PowerShell.
Or better yet, use the Autoruns utility. It is perhaps the only user-friendly way of removing services from Windows and works like a charm. As a bonus, Autoruns lets you clean the Startup list as well, removing any bloatware that might be slowing down boot times.
Related Posts
- How to Fix a “This file does not have an app associated with it” Error on Windows
- How to Fix an Update Error 0x800705b4 on Windows
- How to Resolve “A JavaScript error occured in the main process” Error on Windows
- How to Fix the Network Discovery Is Turned Off Error on Windows
- How to Change Folder Icons in Windows
