How to uninstall a Windows Service when there is no executable for it left on the system?

前端 未结 7 2015
陌清茗
陌清茗 2021-01-29 18:14

How do I uninstall a Windows Service when there is no executable for it left on the system? I can not run installutil -u since there is not executable left on the s

相关标签:
7条回答
  • 2021-01-29 18:28

    My favourite way of doing this is to use Sysinternals Autoruns application. Just select the service and press delete.

    0 讨论(0)
  • 2021-01-29 18:33

    I'd use PowerShell for this

    Remove-Service -Name "TestService"
    

    https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/remove-service

    0 讨论(0)
  • 2021-01-29 18:34

    Create a copy of executables of same service and paste it on the same path of the existing service and then uninstall.

    0 讨论(0)
  • 2021-01-29 18:40

    Here is the powershell script to delete a service foo

    $foo= Get-WmiObject -Class Win32_Service -Filter "Name='foo'"
    $foo.delete()
    
    0 讨论(0)
  • 2021-01-29 18:43

    You should be able to uninstall it using sc.exe (I think it is included in the Windows Resource Kit) by running the following in an "administrator" command prompt:

    sc.exe delete <service name>
    

    where <service name> is the name of the service itself as you see it in the service management console, not of the exe.

    You can find sc.exe in the System folder and it needs Administrative privileges to run. More information in this Microsoft KB article.

    Alternatively, you can directly call the DeleteService() api. That way is a little more complex, since you need to get a handle to the service control manager via OpenSCManager() and so on, but on the other hand it gives you more control over what is happening.

    0 讨论(0)
  • 2021-01-29 18:49

    found here

    I just tried on windows XP, it worked

    local computer: sc \\. delete [service-name]

      Deleting services in Windows Server 2003
    
      We can use sc.exe in the Windows Server 2003 to control services, create services and delete services. Since some people thought they must directly modify the registry to delete a service, I would like to share how to use sc.exe to delete a service without directly modifying the registry so that decreased the possibility for system failures.
    
      To delete a service: 
    
      Click “start“ - “run“, and then enter “cmd“ to open Microsoft Command Console.
    
      Enter command:
    
      sc servername delete servicename
    
      For instance, sc \\dc delete myservice
    
      (Note: In this example, dc is my Domain Controller Server name, which is not the local machine, myservice is the name of the service I want to delete on the DC server.)
    
      Below is the official help of all sc functions:
    
      DESCRIPTION:
        SC is a command line program used for communicating with the
        NT Service Controller and services. 
      USAGE:
              sc
    
    0 讨论(0)
提交回复
热议问题