Check via VBScript whether laptop is connected to electricity?

Hy
4

Hi, I want to use VBScript or, if possible, a batch file or whatever to check whether my laptop is connected to the PC. If this is the case, it should go into the "high performance" battery mode; if it runs on the battery, then it should go into energy-saving mode. How can you do this with self-written (i.e. Not downloaded programs…)?

De

I think that should help you:

https://stackoverflow.com/...a/47581516

Vi

Haven't tested it yet, but it should work.

@echo off

: loop

TIMEOUT / nobreak 2> nul

for / f "delims =" %% A in ('WMIC Path Win32_Battery Get BatteryStatus') do (set / a "batteryStatus = %% A")> nul 2> & 1

if% batteryStatus% EQU 1 goto battery

if% batteryStatus% EQU 2 goto net

:battery pack

powercfg / S a1841308-3541-4fab-bc81-f71556f20b4a

goto loop

:network

powercfg / S 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c

goto loop

Hy

Thank you

Hy

Thanks should work.