Microsoft KB Archive/234001

= Managing Services Using ADSI and Windows Script Host =

Article ID: 234001

Article Last Modified on 8/8/2007

-

APPLIES TO


 * Microsoft Windows NT Server 4.0, Terminal Server Edition
 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Professional Edition
 * Microsoft Windows NT Server 4.0 Standard Edition
 * Microsoft Windows NT Workstation 4.0 Developer Edition
 * Microsoft Active Directory Service Interfaces 2.5

-



This article was previously published under Q234001



SUMMARY
This article describes how to manage services using Active Directory Services Interface (ADSI) and Windows Script Host.



MORE INFORMATION
You can use ADSI and Windows Script Host to write scripts that allow you to manage local and remote services. This article describes the different methods and properties ADSI provides for services, as well as script examples.

The ADSI Service Object supports two COM interfaces, IADsService and IADsServiceOperations.

The properties of the IADsService interface are list in the following table.

The IADsServiceOperations service settings are listed in the following table.

The following example of VBScript code lists the services on a computer with some common properties: Set ComputerObj = GetObject("WinNT://MYCOMPUTER") ComputerObj.Filter = Array("Service") For Each Service in ComputerObj WScript.Echo "Service display name = " & Service.DisplayName WScript.Echo "Service account name = " & Service.ServiceAccountName WScript.Echo "Service executable  = " & Service.Path WScript.Echo "Current status      = " & Service.Status Next

The following Visual Basic script starts the Computer Browser service on MYCOMPUTER:

Set Service = GetObject("WinNT://MYCOMPUTER/BROWSER,Service") Service.Start

The following Visual Basic script sets the user account and password for the Directory Replicator service on MYCOMPUTER:

Set Service = GetObject("WinNT://MYCOMPUTER/REPLICATOR,Service") Service.ServiceAccountName = "ARCADIABAY\JSmith" Service.SetPassword "TopSecret" Service.SetInfo

For information about ADSI, please visit the following Microsoft Web site:

http://www.microsoft.com/technet/prodtechnol/windows2000serv/technologies/activedirectory/default.mspx

For information about Windows Script Host, VBScript, and JScript, please visit the following Microsoft Web site:

http://msdn2.microsoft.com/en-us/library/ms950396.aspx

Keywords: kbenv kbhowto KB234001

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.