Windows OS Hub
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux

 Windows OS Hub / Windows 11 / How to Delete a Windows Service via CMD or PowerShell

October 20, 2025

How to Delete a Windows Service via CMD or PowerShell

After uninstalling certain programs or tools, unused services may still be present in Windows. This article explains how to properly remove a service in Windows using the built-in CMD or PowerShell tools.

The Services graphical management snap-in (services.msc) in Windows only provides basic action buttons for starting, pausing, or stopping a service. This console cannot be used to remove the service.

For example, the task is to remove the unused Stunnel TLS wrapper service (in my case, this service was used to encrypt app traffic with Stunnel). First, get the service name. In this case, it is stunnel (copy the name from the Service name field).

how to delete unused windows service

I strongly advise you to exercise caution when removing services and to thoroughly understand the potential impact of your actions. To avoid disrupting your environment, it is recommended to disable the service and observe its operation for some time before removing it. You can disable the service’s automatic startup using the following PowerShell command:

Set-Service stunnel –startuptype disabled –passthru
Stop-Service stunnel

disable and stop service using powershell

Also, before deleting a service, check the DependentServices parameter to see which other services depend on it.

Get-Service stunnel -DependentServices

You must stop the service before you can remove it. Click the Stop button in the Services console or run the command:

net stop stunnel

net stop service - cmd

Service settings are stored in the registry under the HKLM\SYSTEM\CurrentControlSet\Services key.

Before deleting a service, back up its settings by exporting the service configuration to a REG file with the following command:

reg export "HKLM\SYSTEM\CurrentControlSet\Services\stunnel" "%HOMEPATH%\Documents\stunnel_backup.reg" /y

service registry key

Now you can delete a service by its name using the built-in sc.exe command (if the service name contains spaces, enclose it in quotation marks):

sc delete stunnel

A message should appear:

[SC] DeleteService SUCCESS

sc delete - [SC] DeleteService SUCCESS

The sc.exe tool allows you to manage services on remote computers. To stop and remove the service on the M-FS01computer, run;

sc.ee \\m-fs01 stop ServiceName1
sc.exe \\m-fs01 delete ServiceName1

Or you can remove a service using PowerShell:

Remove-Service stunnel

remove-service powershelle

The Remove-Service cmdlet is available in PowerShell Core versions 6.x and newer.

In Windows PowerShell 5.1, which doesn’t contain the Remove-Service command, you can use WMI to remove a service:

$service = Get-WmiObject -Class Win32_Service -Filter "Name='stunnel'"
$service.delete()

Also, to remove a service, you can delete its registry key under HKLM\SYSTEM\CurrentControlSet\Services. To ensure you are targeting the correct service for removal, find the service in the list and verify that the DisplayName and ImagePath parameters contain the service’s name and the complete path to its executable file. Delete the entire service key.

delete service key from the registry

Press F5 to refresh the Services console list and verify that the service has been removed and no longer appears. It is usually recommended to restart Windows after removing a service. After rebooting, you can delete the executable files and directories that are referenced by the ImagePath registry value.

When deleting some services via the CMD, a message may appear saying the service is marked for deletion, indicating it is scheduled for removal but may require closing related handles or a system restart to complete the process.

DeleteService FAILED 1072:
The specified service has been marked for deletion.

This service will be automatically removed after the computer restarts.

To remove a service without restarting Windows, use the taskill command or terminate the service’s running executable process from Task Manager. Then delete the service registry key using the following PowerShell command:

Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\stunnel | Remove-Item -Force -Verbose

0 comment
1
Facebook Twitter Google + Pinterest
Windows 10Windows 11
previous post
Force Stop an Unresponsive VM on Proxmox
next post
Restoring a Missing Windows Update Service in Windows 11 (10)

Related Reading

Configuring RemoteApps Hosted on Windows 10/11 (without Windows...

January 25, 2025

Disable BitLocker Automatic Drive Encryption in Windows 11

October 16, 2024

Bridging Multiple Network Interfaces on Windows

November 21, 2024

Fix: Windows Update Tab (Button) is Missing from...

December 16, 2024

How to Prefer IPv4 over IPv6 in Windows...

April 15, 2025

Find a Process Causing High Disk Usage on...

July 16, 2025

Change BIOS from Legacy to UEFI without Reinstalling...

April 23, 2025

Map a Network Drive over SSH (SSHFS) in...

May 13, 2025

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • How to Delete a Windows Service via CMD or PowerShell

    October 16, 2025
  • Resource Fair Sharing in Windows Server Remote Desktop Services (RDS)

    October 6, 2025
  • How to Disable (Enable) Credential Guard in Windows 11

    October 6, 2025
  • Wrong Network Profile on Windows Server after Reboot

    September 30, 2025
  • How to Get Windows 10 Extended Security Updates After End-Of-Life

    September 24, 2025
  • Blocking NTLM Connections on Windows 11 and Windows Server 2025

    September 23, 2025
  • Windows Stucks at ‘Getting Windows Ready, Don’t Turn Off Computer’

    September 15, 2025
  • Clean Up ETL Log Files in ProgramData

    September 9, 2025
  • Fix: Slow Startup of PowerShell Console and Scripts

    September 3, 2025
  • DPI Scaling and Font Size in RDP (RDS) Session

    August 27, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Upgrading to Windows 11 on Unsupported Hardware
  • Create a Custom Windows Image with Pre-installed Apps
  • Converting Windows 10 to Enterprise LTSC Without Losing Data
  • Configuring RemoteApps Hosted on Windows 10/11 (without Windows Server)
  • Permanently Disable Driver Signature Enforcement on Windows 11
  • How to Assign (Passthrough) a Physical GPU to a Hyper-V Virtual Machine
  • Get Started with Docker on Windows (WSL2) without Docker Desktop
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top