Install and Uninstall Windows Service using PowerShell

In this article, you can learn how to Install and Uninstall Windows Service using InstallUtil.exe utility. InstallUtil.exe is the command-line utility which is available in .NET framework installation folder.


Install and Uninstall Windows Service using InstallUtil.exe:

The windows service applications which are created using .NET Framework, uses the command line utility InstallUtil.exe to install and uninstall the services. This tool is usually available in under Microsoft .NET framework installation path. The version number can be vary.

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe

Install Windows services PowerShell:

To install .NET service, you need to run the below command by using PowerShell by specifying the full path of the .NET service application.


New-Service -Name “MyService” -BinaryPathName “D:\MyApp\MyService.exe”

UnInstall Windows services using PowerShell:

To Uninstall .NET service you need to run the below command by using PowerShell by specifying the service name only.


Remove-Service -Name “MyService”

Please note that, the service entry might be still present in the registry even after uninstalling the service using PowerShell command. In this case, you need to run the sc.exe delete to remove the entry from the registry.


sc.exe delete “MyService”

Note: The v4.0.30319 is the framework version.


– Article ends here –

Recommended:   How to log Windows Service custom logs in C#
Share this:

Kiran is a Software engineer by profession and Enthusiastic blogger, love to write articles on computer technology and programming. Reach him at kiran.troubleshootyourself@gmail.com.

We will be happy to hear your thoughts

Leave a reply

Troubleshootyourself
Logo