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);