wmi - Change LogOn properties of a SQL server instance -


i want change logon properties of sql server 2008 r2 instance using code. manually can in sql server configuration manager right clicking on instance name->log on. under built-in account change network service local service. click on apply. sql instance restarted effect changes.

now hoe can same(network service local service) using code .i think can done using wmi. please me on this.

changing logon properties network service localsystem can done using wmi.

use change method of win32_service class

in change method specify first 6 parameters blank , specify startname localsystem(you can specify other parameters such login names if required) , startpassword blank password(blank password in case of localsystem).

below vbscript it.

strcomputer = "." set objwmiservice = getobject _     ("winmgmts:\\" & strcomputer & "\root\cimv2") set colservices = objwmiservice.execquery _     ("select * win32_service name = 'mssql$instancename'") each objservice in colservices     errreturn = objservice.change( , , , , , , "localsystem","")      next 

also see this link more information


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -