Service Description Parameter Missing? - Installing A Service Remotely.

  • Thread starter Thread starter Philip Borchert
  • Start date Start date
P

Philip Borchert

Guest
Good Afternoon, Ive been working on trying to install a service remotely with WMI and have it working, but it doesnt seem like you can set the "Service Description" when you create the service? Is there any documentation that explains why this is? The Service Description appears in the Service Control Managers (services.msc). Here is my code for reference.

public static ReturnValue InstallService(string serviceName, string serviceDisplayName, string serviceDescription, string servicePath, ServiceType serviceType
,OnError errorHandle, StartMode serviceStartMode, bool interactWithDesktop, string serviceStartName
,string servicePassword, string loadOrderGroup, string[] loadOrderGroupDependencies, string[] serviceDependencies)
{
ManagementClass mc = new ManagementClass("Win32_Service");
ManagementBaseObject inParams = mc.GetMethodParameters("create");
inParams["Name"] = serviceName;
inParams["DisplayName"] = serviceDisplayName;
inParams["PathName"] = servicePath;
inParams["ServiceType"] = serviceType;
inParams["ErrorControl"] = errorHandle;
inParams["StartMode"] = serviceStartMode.ToString();
inParams["DesktopInteract"] = interactWithDesktop;
inParams["StartName"] = serviceStartName;
inParams["StartPassword"] = servicePassword;
inParams["LoadOrderGroup"] = loadOrderGroup;
inParams["LoadOrderGroupDependencies"] = loadOrderGroupDependencies;
inParams["ServiceDependencies"] = serviceDependencies;

try
{
ManagementBaseObject outParams = mc.InvokeMethod("create", inParams, null);

if (outParams != null)
return (ReturnValue)Enum.Parse(typeof(ReturnValue), outParams["ReturnValue"].ToString());
}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
return ReturnValue.UnknownFailure;
}

Please explain why you cannot set the service description while creating the service.

Continue reading...
 
Back
Top