kamagra bombone novi sad

Thursday, August 25, 2016

Setting Windows Service account dynamically

November 5, 2009 by · Leave a Comment 

Often we need to change the windows service account to our needs or when a new user is logged in who has not installed the service. Here is a quick way to check and change the service account.

string objPath = string.Format("Win32_Service.Name='{0}’", serviceName);
using (ManagementObject service = new ManagementObject(new ManagementPath(objPath)))
object[] wmiParams = new object[11];
wmiParams[6] = username;
wmiParams[7] = password;
service.InvokeMethod("Change", wmiParams);

Top Blogs

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!