Windows 11 Quick Settings Battery Icon

Mark Bewley 51 Reputation points
2025-05-25T16:28:59.1433333+00:00

Windows 11 Explorer Desktop appears to not work properly if a battery is added after login.

I am validating a custom UPS battery driver. It is based on https://learn.microsoft.com/en-us/samples/microsoft/windows-driver-samples/simbatt-simulated-battery-driver-sample/

The workflow we have adopted means the battery driver may not appear in Device Manager until after a user has logged in.

This is because we require some valid communication with the UPS before calling, SwDeviceCreate(). The communication is done via an application that is run in user space, under the logged in user, which in turn communicates with a service application that can make the "elevated" call into the kernel.

The battery icon is never shown in the System Tray. There are some circumstances where it can appear (after a while) in the lower-left corner of the Quick Settings dialog - I have not done enough testing to determine a pattern.

The battery appears in the Settings, System | Power & battery screens. Notification messages are shown on the low and critical battery capacity levels.

It is just the Explorer Desktop this is not displaying a battery status to the user.

If I use Task Manager to kill and restart explorer.exe, a battery icon does appear in the System Tray and disappears and reappears as I close and create the driver entry - but it still takes a while before the icon appears in the lower-left corner of the Quick Settings dialog.

Until the restart of the desktop process the icon is never shown in the System Tray.

Similarly, on SwDeviceClose() it takes a while before the icon disappears from the lower-left corner of the Quick Settings dialog. It does change to an X image (but reports 100%).

This testing is being performed on Windows 11 IoT Enterprise LTSC 2024, build 26100.4061. I have not checked the behaviour on other "consumer" releases of Windows 11.

Previous testing was performed on Windows 10 IoT Enterprise LTSC 2021, which did not present any of these issues, although the Desktop Experience is very different.

As this is a niche case, whether anyone else has experienced this.

If it were to be reported\escalated to Microsoft, I am not sure what the process would be to do this.

Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Henry Mai 1,970 Reputation points Independent Advisor
    2025-05-27T16:40:25.1333333+00:00

    Hi, I'm Henry! I will help you with this.

    Here's a breakdown of potential causes, things to investigate:

    Potential Causes & Areas to Investigate:

    1. Shell Notification/Refresh Logic Change in Windows 11:
      • Explorer might perform an initial scan for battery devices at login/startup and then rely on specific notifications that your SwDeviceCreate() flow (or the underlying PnP system's notification to the shell) isn't triggering correctly or promptly for the already running Explorer instance.
    2. Timing of SwDeviceCreate():
      • Creating the device after the user has logged in and Explorer is fully initialized is the critical factor. The shell might have already "decided" there's no battery.
    3. Driver Capabilities & Properties:
      • Are there any specific PnP device capabilities or properties that the Windows 11 shell might query to determine if it should display a battery icon, beyond the basic battery class presence? While unlikely to be the root cause if Settings sees it, it's a remote possibility.

    Troubleshooting & Further Investigation:

    1. Programmatic Shell Refresh (From your Service):
      • Since your service has elevated privileges, after SwDeviceCreate succeeds, you could try programmatically telling the shell to refresh.
      • The way is SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSHNOWAIT, NULL, NULL); which forces a lot of the shell to re-evaluate things.
      • You could also try broadcasting a WM_SETTINGCHANGE message. For example: SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)L"Policy", SMTO_ABORTIFHUNG, 5000, NULL); or specifically for power-related settings if such a string exists.
    2. Event Tracing for Windows (ETW):
      • Monitor ETW traces focusing on:
      • PnP events: Microsoft-Windows-Kernel-PnP
      • Power events: Microsoft-Windows-PowerCfg, Microsoft-Windows-Kernel-Power
      • Shell events: This is trickier, but look for providers related to Explorer, ShellExperienceHost, or SystemTray.
      • Capture traces during the scenario:
      1. Start tracing.
      2. Log in.
      3. Trigger your application to call SwDeviceCreate().
      4. Observe icon behavior.
      5. Kill and restart explorer.exe.
      6. Observe icon behavior.
      7. Trigger SwDeviceClose().
      8. Stop tracing.
      • Compare the events when the icon doesn't appear vs. when it does after an Explorer restart. Look for specific notifications that Explorer might be missing or ignoring.
    3. API Monitor / Process Monitor:
      • Use Process Monitor (Sysinternals) to filter on explorer.exe. Look for registry queries or file accesses related to power, battery, or system icons when the device is created. See what happens differently before and after the explorer.exe restart.
      • API Monitor could show what Windows APIs Explorer is calling related to device enumeration or UI updates.
    4. Check SW_DEVICE_CREATE_INFO:
      • Review all parameters passed to SwDeviceCreate, especially pszInstanceId, pszzHardwareIds, pszzCompatibleIds, and CapabilityFlags. Ensure they are absolutely correct and consistent. Perhaps a subtle change in how Win11 interprets these for shell purposes.

    Please do share if you find a solution.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.