Installing services from PowerShell (the elaborate way)

Since we’ve got access to all classes and namespaces in the .net Framework in PowerShell, let’s have some fun.

Normally you install Windows services through the sc command or the installutil tool from Microsoft. But what does the installutil, exactly?

Basically it parses the incoming input and — if not specified otherwise — passes it through into a function called InstallHelper() in the System.Configuration.Install namespace. We can do the same with PowerShell, leaving out all the pesky problems of finding a suitable instance of installutil:

[System.Configuration.Install.ManagedInstallerClass]::InstallHelper("MyService.exe")

If run with elevated rights you should see that the transaction is successful and your service should show up in Computer Management.

Published by

tsukasa

The fool's herald.

Leave a Reply

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