/// <summary> /// Delete a service. /// </summary> /// <param name="name">The name of the service.</param> /// <param name="throw_on_error">True to throw on error.</param> /// <returns>The NT status.</returns> public static NtStatus DeleteService(string name, bool throw_on_error) { using (var service = OpenService(name, ServiceAccessRights.Delete, throw_on_error)) { if (!service.IsSuccess) { return(service.Status); } return(Win32NativeMethods.DeleteService(service.Result).GetLastWin32Error().ToNtException(throw_on_error)); } }