我正在测试几台安装了 Windows 的笔记本电脑,我需要编写代码来计算“充满电”所需的时间(以秒或分钟为单位)——Windows 显示的值,以及完全放电所需的时间。指示完全放电所需的分钟数的值包含在 PowerStatus.BatteryLifeRemaining 属性中。
我找不到在哪里可以读取充满电所需的时间。我不想计算它,因为我需要与 Windows 显示的时间完全相同的时间。
CIM_Battery 方法、Win32_Battery、Win32_PortableBattery 和 PowerStatus 不提供此信息。
--- BatteryStatus --- BatteryStatus 实例 { Active = TRUE; ChargeRate = 717; Charging = TRUE; Critical = TRUE; DischargeRate = 0; Discharging = FALSE; InstanceName = "ACPI\PNP0C0A\0_0"; PowerOnline = TRUE; RemainingCapacity = 1573; Tag = 1; Voltage = 12543; };
--- Win32_Battery --- Win32_Battery 的实例 { Availability = 2; BatteryStatus = 2; Caption = “内置电池”; Chemistry = 6; CreationClassName = “Win32_Battery”; Description = “内置电池”; DesignVoltage = “12543”; DeviceID = “2128SDIDell”; EstimatedChargeRemaining = 87; EstimatedRunTime = 71582788; Name = “Dell”; PowerManagementCapabilities = {1}; PowerManagementSupported = FALSE; Status = “OK”; SystemCreationClassName = “Win32_ComputerSystem”; SystemName = “HOME_PC”; };
--- Win32_PortableBattery --- Win32_PortableBattery 的实例 { CapacityMultiplier = 10; Caption = "便携式电池"; Chemistry = 2; CreationClassName = "Win32_PortableBattery"; Description = "便携式电池"; DesignCapacity = 44000; DesignVoltage = "11100"; DeviceID = "便携式电池 0"; Location = "系统电池托架"; Manufacturer = "SDI "; MaxBatteryError = 0; Name = "SDI "; SmartBatteryVersion = "Bat123"; SystemCreationClassName = "Win32_ComputerSystem"; SystemName = "HOME_PC"; };
--- BatteryStaticData --- BatteryStaticData 实例 { Active = TRUE; Capabilities = 2147483648; Chemistry = 1313818956; CriticalBias = 0; DefaultAlert1 = 0; DefaultAlert2 = 179; DesignedCapacity = 4400; DeviceName = "Dell"; Granularity0 = "100"; Granularity1 = "18897856102400"; Granularity2 = "0"; Granularity3 = "0"; InstanceName = "ACPI\PNP0C0A\0_0"; ManufactureDate = "**************.**********"; ManufactureName = "SDI"; SerialNumber = "2128"; Tag = 1; Technology = 0; UniqueID = "2128SDIDell"; };
--- BatteryDesignedCapacity --- 没有返回有关 BatteryDesignedCapacity spacename 的信息!
--- BatteryFullChargedCapacity --- BatteryFullChargedCapacity 实例 { Active = TRUE; FullChargedCapacity = 1796; InstanceName = “ACPI\PNP0C0A\0_0”; Tag = 1; };
--- BatteryRuntime --- BatteryRuntime 实例 { Active = TRUE; EstimatedRuntime = 4294967295; InstanceName = “ACPI\PNP0C0A\0_0”; Tag = 1; };
--- BatteryCycleCount --- BatteryCycleCount 实例 { Active = TRUE; CycleCount = 0; InstanceName = "ACPI\PNP0C0A\0_0"; Tag = 1; };
--- 电池温度 --- 没有返回有关电池温度空间名称的信息!
--- MSBatteryClassEvent --- 没有返回 MSBatteryClassEvent spacename 的信息!
--- BatteryStatusChange --- 没有返回有关 BatteryStatusChange spacename 的信息!
--- BatteryTagChange --- 没有返回有关 BatteryTagChange spacename 的信息!
--- MSBatteryClass --- BatteryCycleCount 实例 { Active = TRUE; CycleCount = 0; InstanceName = "ACPI\PNP0C0A\0_0"; Tag = 1; };
BatteryRuntime 实例 { Active = TRUE; EstimatedRuntime = 4294967295; InstanceName = “ACPI\PNP0C0A\0_0”; Tag = 1; };
BatteryStaticData 实例 { Active = TRUE; Capabilities = 2147483648; Chemistry = 1313818956; CriticalBias = 0; DefaultAlert1 = 0; DefaultAlert2 = 179; DesignedCapacity = 4400; DeviceName = “Dell”; Granularity0 = “100”; Granularity1 = “18897856102400”; Granularity2 = “0”; Granularity3 = “0”; InstanceName = “ACPI\PNP0C0A\0_0”; ManufactureDate = “**************.**********”; ManufactureName = “SDI”; SerialNumber = “2128”; Tag = 1; Technology = 0; UniqueID = “2128SDIDell”; };
BatteryFullChargedCapacity 实例 { Active = TRUE; FullChargedCapacity = 1796; InstanceName = “ACPI\PNP0C0A\0_0”; Tag = 1; };
BatteryStatus 实例 { Active = TRUE; ChargeRate = 717; Charging = TRUE; Critical = TRUE; DischargeRate = 0; Discharging = FALSE; InstanceName = "ACPI\PNP0C0A\0_0"; PowerOnline = TRUE; RemainingCapacity = 1573; Tag = 1; Voltage = 12543; };
我可以通过 PowerShell 获取剩余的放电时间(分钟)(“BatteryLifeRemaining”参数 - 与 Windows 显示的相同),通过 PowerStatus,但不能获取“完全充电时间” - BatteryFullLifetime 参数始终为 -1。
通过 Windows PowerShell 获取“完全充电时间”(与窗口显示的相同)的方法对我很有帮助。