HOW TO MANAGE SQL SERVER 2000 Services USING WMI

There are quite a few blog posts out there to manage SQL Server 2005 services using the :\\.\root\Microsoft\SqlServer\ComputerManagement\

However, WMI Admin Provider is not pre-installed for SQL Server 2000. It needs to be installed separately using the WMI Admin Provider Setup available along with the SQL Server 2000 Setup CD under x86\other\wmi folder.

 

Reference
======

Sample script to change SQL Server 2005 service startup account and password using WMI:
https://blogs.msdn.com/mwories/archive/2006/11/03/wmi_5F00_change_5F00_password.aspx

MSDN Documentation on Win32_Service class
https://msdn.microsoft.com/en-us/library/aa394418.aspx

 

Sample Script to change a SQL Server 2000 instance startup account using root\MicrosoftSQLServer namespace:

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftSQLServer")
 
' Obtain an instance of the the class

' using a key property value.

Set objShare = objWMIService.Get("Win32_Service.Name='MSSQL$SQL2000'")

' Obtain an InParameters object specific

' to the method.

Set objInParam = objShare.Methods_("Change"). _ inParameters.SpawnInstance_()

' Add the input parameters.

objInParam.Properties_.Item("StartName") = "LocalSystem"

objInParam.Properties_.Item("StartPassword") = ""

' Execute the method and obtain the return status.

' The OutParameters object in objOutParams

' is created by the provider.

Set objOutParams = objWMIService.ExecMethod("Win32_Service.Name='MSSQL$SQL2000'", "Change", objInParam)

' List OutParams

Wscript.Echo "Out Parameters: "Wscript.echo "ReturnValue: " & objOutParams.ReturnValue

The script above changes the Startup Account of an instance called SQL2000. For changing the startup account of a default instance, we need to make the following change:

Win32_Service.Name = MSSQLServer
For a named instance, you would change it to:

Win32_Service.Name = MSSQL$<instance name>
Where <instance name> = Name of the SQL 2000 named instance

The other parameters of interest are:

objInParam.Properties_.Item("StartName")
The above parameter holds the new Startup Account

objInParam.Properties_.Item("StartPassword")
The above parameter holds the password.

If you had to change it to Local System or Network Service, then you don’t need to provide a value for StartPassword parameter.

NOTE: This should be done when there is no other option. The best way to change the startup account in SQL Server 2000 is to use Enterprise Manager.

Amit Banerjee
Technical Lead, Microsoft Sql Server