Cannot set friendly name for device in Windows 7

In my UMDF device driver I set a friendly name for my device programatically:

HRESULT CMyDevice::SetFriendlyDeviceName(WCHAR * FriendlyName)
{
HRESULT hr = HRESULT_FROM_WIN32(ERROR_GEN_FAILURE);
CComPtr upsf = NULL;

hr = m_FxDevice->QueryInterface(&upsf);
if (SUCCEEDED(hr))
{
CComPtr ups = NULL;
WDF_PROPERTY_STORE_ROOT rs;

RtlZeroMemory(&rs, sizeof(WDF_PROPERTY_STORE_ROOT));
rs.LengthCb = sizeof(WDF_PROPERTY_STORE_ROOT);
rs.RootClass = WdfPropertyStoreRootClassHardwareKey;
rs.Qualifier.HardwareKey.ServiceName = NULL;

hr = upsf->RetrieveUnifiedDevicePropertyStore(&rs, &ups);
if (SUCCEEDED(hr))
{
ULONG len = ((ULONG)wcslen(FriendlyName) * sizeof(WCHAR)) + sizeof(WCHAR);

hr = ups->SetPropertyData(&DEVPKEY_Device_FriendlyName, 0, 0, DEVPROP_TYPE_STRING, len, FriendlyName);
if (FAILED(hr))
TraceEvents(TRACE_LEVEL_WARNING, TRACE_DEVICE, “Failed to set friendly name for device: %x”, hr);
else
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DEVICE, “Friendly name for device successfully set”);
}
else
TraceEvents(TRACE_LEVEL_WARNING, TRACE_DEVICE, “Failed to retrieve unified device property store: %x”, hr);
}
else
TraceEvents(TRACE_LEVEL_WARNING, TRACE_DEVICE, “Failed to retrieve unified property store factory: %x”, hr);

}

It works in Windows 8 and 10. The problem is it does not work in Windows 7 and Vista. Although I get no errors when executing above code and it says “Friendly name for device successfully set”, the friendly name does not change in Device Manager. It also does not change after refreshing the device list. When I look into the hadware key of my device in the registry HKLM\SYSTEM\CurrentControlSet\Enum\USB\VID_XXXX&PID_XXXX\XXXX the value for “FriendlyName” is missing. When I add it manually it shows up in Device Manager.