def _set_wmi_setting(wmi_class_name, setting, value, server):
    '''
    Set the value of the setting for the provided class.
    '''
    with salt.utils.winapi.Com():
        try:
            connection = wmi.WMI(namespace=_WMI_NAMESPACE)
            wmi_class = getattr(connection, wmi_class_name)

            objs = wmi_class(Name=server)[0]
        except wmi.x_wmi as error:
            _LOG.error('Encountered WMI error: %s', error.com_error)
        except (AttributeError, __HOLE__) as error:
            _LOG.error('Error getting %s: %s', wmi_class_name, error)

        try:
            setattr(objs, setting, value)
            return True
        except wmi.x_wmi as error:
            _LOG.error('Encountered WMI error: %s', error.com_error)
        except AttributeError as error:
            _LOG.error('Error setting %s: %s', setting, error)
    return False
dataset/ETHPy150Open saltstack/salt/salt/modules/win_smtp_server.py/_set_wmi_setting