I have several computers with cameras connected to them via USB. I figured that after more than 30 hours of utilization, the cameras would disconnect from the computer. The reason seem to be related to a Device Manager USB property called “Allow the computer to turn off this device to save power”. When this property is unchecked, my cameras keep running fine. My problem is that I have quite a number of computer to check, and I was worried that this setting might be reset during a Windows update.
Is there a programmatic way to check and turn off the: “Allow the computer to turn off this device to save power” property for all USBs connected to the computer? I am more versed in Python, but I’m open to any programmatic solution.
I tested quite thoroughly and I know this is the property that needs to be unchecked. I don’t know if there’s a more general setting that would prevent this behavior though.
When reviewing other StackExchange questions, I found:
USB port current value
The question doesn’t have an accepted answer, but @Massimiliano Peluso suggested to use WMI and even provided a C# code. I figured that Python has a WMI wrapper, and tried to use it as described on the microsoft forum: https://learn.microsoft.com/en-us/answers/questions/1663906/collecting-system-information-using-python:
import wmi
c = wmi.WMI()
print(c.Win32_USBControllerDevice()[0].Dependent)
I just printed the first item in the list to get an idea of its properties, and this is the print:
instance of Win32_PnPEntity
{
Caption = "USB Root Hub (USB 3.0)";
ClassGuid = "{36fc9e60-c465-11cf-8056-444553540000}";
ConfigManagerErrorCode = 0;
ConfigManagerUserConfig = FALSE;
CreationClassName = "Win32_PnPEntity";
Description = "USB Root Hub (USB 3.0)";
DeviceID = "USB\ROOT_HUB30\4&2FD48294&0&0";
HardwareID = {"USB\ROOT_HUB30&VID8086&PID7A60&REV0011", "USB\ROOT_HUB30&VID8086&PID7A60", "USB\ROOT_HUB30"};
Manufacturer = "(Standard USB HUBs)";
Name = "USB Root Hub (USB 3.0)";
PNPClass = "USB";
PNPDeviceID = "USB\ROOT_HUB30\4&2FD48294&0&0";
Present = TRUE;
Service = "USBHUB3";
Status = "OK";
SystemCreationClassName = "Win32_ComputerSystem";
SystemName = "DESKTOP-OK0U0D5";
};
@Massimiliano Peluso mentions that the “Allow the computer to turn off this device to save power” should be in the Availability
property, but I do not find such property. When I navigate to the description of the Win32_PnpEntity
: https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-pnpentity, the property is listed there, but somehow I cannot get it through Python.