Installing and Removing Services

Microsoft® Windows® 2000 Scripting Guide

WMI provides methods that allow you to install and remove services programmatically. These methods work best for installing and removing third-party services rather than services that are part of the operating system. It is difficult (or impossible) to install operating system services using WMI, if for no other reason than the fact that you are unlikely to have a detailed list of the executable files and the service accounts required for each service.

And while it is possible to remove operating system services using WMI, this is not recommended. This is because the service removal will be incomplete: for example, the service will no longer function, but it will still be listed as Installed in Windows Components. If you need a command-line method for installing or removing operating system services, you can use Sysocmgr.exe instead; however, Sysocmgr.exe is designed to work on the local computer and not on remote computers.

Although it is somewhat limited in scope, WMI can be useful in the following situations:

  • You need to install an in-house service on multiple computers.

  • You need to replace a third-party service previously used in your organization.

    For example, your script could check for the presence of this service on each computer in your organization and, if found, stop and remove the service. The script could then install the replacement service.