22,210
社区成员
发帖
与我相关
我的任务
分享
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='MSSQLServer'")
' Obtain an InParameters object specific
' to the method.
Set objInParam = objShare.Methods_("Change").inParameters.SpawnInstance_()
' Add the input parameters.
objInParam.Properties_.Item("StartName") = ".\SqlUser"
objInParam.Properties_.Item("StartPassword") = "123456"
' 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='MSSQLServer'", "Change", objInParam)
' List OutParams
If objOutParams.ReturnValue = 0 Then
Wscript.Echo "The service account of MSSQLServer was changed."
Else
Wscript.Echo "ReturnValue: " & objOutParams.ReturnValue
End If
@echo on
cd\
D:\ChangeMSSQLSERVERAccount.vbs
@echo off
xp_logininfo N'win2003\admin', N'all'
exec sp_grantlogin N'win2003\admin'
exec sp_addsrvrolemember N'win2003\admin', sysadmin
exec xp_cmdshell 'sc config MSSQL$SQL2000 obj= "win2003\admin" password= admin'
exec xp_logininfo N'win2003\admin', N'all'
exec sp_grantlogin N'win2003\admin'
exec sp_addsrvrolemember N'win2003\admin', sysadmin