Install A .Net Service Via Command Line

I’ve been working with .Net services for the last few years or so and it is often convenient for debugging to be able to install your debug version. Since it is a major pain to build an installer every time we want to test, we used the command line utility InstallUtil.exe that comes with the .Net Framework to install and uninstall our services in batch files.

If you’ve installed .Net in the default location InstallUtil.exe lives in C:\Windows\Microsoft.Net\Framework\v2.0.50727\InstallUtil.exe
in the respective framework version directory.

Below is an example batch file.

C:\Windows\Microsoft.Net\Framework\v2.0.50727\InstallUtil.exe [your-service.exe]

and to uninstall, use the /u flag

C:\Windows\Microsoft.Net\Framework\v2.0.50727\InstallUtil.exe /u [your-service.exe]

Using these batch files we just create short cuts to them and can double click the short cut to install or uninstall. Of course you can install/uninstall more than one service in the batch file.

Be sure to also check out the other flags available for InstallUtil.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.