Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
As your organization changes, you might decide to remove certain services from certain computers. In-house and third-party services can be removed by using WMI, while operating system services can be removed by using Sysocmgr.exe.
When preparing to remove services, keep the following information in mind:
If the service is running when you issue the delete command, the service is marked for deletion, but it continues to run until it stops and all open handles are closed. If the service is never stopped, that service will never be deleted.
Removing a service by using WMI deletes the related registry entries under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services. As a result, the service is no longer installed and is not available through the Services snap-in. However, WMI does not delete the executable file, meaning you could easily reinstall the service. To delete the executable file, you must retrieve the path name and then delete the file.
For example, if you remove the DHCP service by using a WMI script, the DHCP service is no longer listed in the Services snap-in. However, a nonfunctioning shortcut to the DHCP console remains in the Administrative Tools menu, and if you start the Windows Component Wizard, it indicates that the DHCP service is installed.
Because of this, you should always use Sysocmgr.exe to programmatically remove Windows 2000 services.
Listing 15.23 contains a script that removes a service named DbService. To carry out this task, the script must perform the following steps:
Listing 15.23 Removing a Service
|
|
Send us your feedback | « Previous | Next » |