public override uint Create(string Name, string DisplayName, string PathName, ushort ServiceType, byte ErrorControl, string StartMode, bool DesktopInteract, string StartName, string StartPassword, string LoadOrderGroup, string[] LoadOrderGroupDependencies, string[] ServiceDependencies) { byte b = 0; if (ServiceType != 256) { b = byte.Parse(ServiceType.ToString()); } ManagementClass processClass = wmi.GetManagementClass("Win32_Service"); ManagementBaseObject inbo = processClass.GetMethodParameters("Create"); inbo["Name"] = Name; inbo["DisplayName"] = DisplayName; inbo["PathName"] = PathName; inbo["ServiceType"] = b; inbo["ErrorControl"] = ErrorControl; inbo["StartMode"] = StartMode; inbo["DesktopInteract"] = DesktopInteract; inbo["StartName"] = StartName; inbo["StartPassword"] = StartPassword; inbo["LoadOrderGroup"] = LoadOrderGroup; inbo["LoadOrderGroupDependencies"] = LoadOrderGroupDependencies; inbo["ServiceDependencies"] = ServiceDependencies; ManagementBaseObject outbo = processClass.InvokeMethod("Create", inbo, null); uint a = (uint)outbo["ReturnValue"]; return(a); }
public uint EnableDNS(string DNSHostName, string DNSDomain, string[] DNSServerSearchOrder, string[] DNSDomainSuffixSearchOrder) { ManagementClass processClass = wmi.GetManagementClass("Win32_NetworkAdapterConfiguration"); ManagementBaseObject inParams = processClass.GetMethodParameters("EnableDNS"); inParams["DNSHostName"] = DNSHostName; inParams["DNSDomain"] = DNSDomain; inParams["DNSServerSearchOrder"] = DNSServerSearchOrder; inParams["DNSDomainSuffixSearchOrder"] = DNSDomainSuffixSearchOrder; ManagementBaseObject outParams = processClass.InvokeMethod("EnableDNS", inParams, null); uint a = (uint)outParams["ReturnValue"]; return(a); }