How do I find the screen brightness with cmd on Windows?
Asked Answered
M

3

7

I have a code that I am writing that can change the screen brightness according to user input, but this is based around the current screen brightness. Is there a way to obtain the screen brightness as an integer from command prompt?

In the past I have tried to do this by using the Power Config utility in cmd, but it failed. I tried looking it up and didn't find anything for Windows. The nearest solution I found was for IOS and Android.

I got lost after trying the following:

C:\Users\[me]>powercfg /q | find "(Display brightness)"
    Power Setting GUID: aded5e82-b909-4619-9949-f5d71dac0bcb  (Display brightness)

C:\Users\[me]>

I expected a value for screen brightness like '45' or '45%' to be returned, but it gave me a display ID instead. What do I do?

Mortality answered 15/5, 2019 at 12:43 Comment(0)
D
7

You were close. Here is how you do it.

The format of powercfg is:

POWERCFG -SETDCVALUEINDEX <SCHEME_GUID> <SUBGROUP_GUID> <SETTING_GUID> value

To find out your information:

For <SCHEME_GUID>:

powercfg /q | findstr Scheme
Power Scheme GUID: a3e508ca-5ab1-4c55-bee1-9edfb71ba0a4  (HP Optimized (recommended))

For <SUBGROUP_GUID> and <SETTING_GUID>:

powercfg /q | findstr Display
  Subgroup GUID: 7516b95f-f776-4464-8c53-06167f40ca19  (Display)
    Power Setting GUID: aded5e82-b909-4619-9949-f5d31dac0bcb  (Display brightness)

Now with the GUID values and brightness in percentage - lets say 23% - like this:

powercfg -SetDcValueIndex a3e508ca-5ab1-4c55-bee1-9edfb71ba0a4 7516b95f-f776-4464-8c53-06167f40ca19 aded5e82-b909-4619-9949-f5d31dac0bcb 23

Edit: To view current britness level:

Check your current settings with the GUID: aded5e82-b909-4619-9949-f5d71dac0bcb

Just let the powercfg /q > current_settings.txt. Will save the output to current_settings.txt file and there search for the aded5e82-b909-4619-9949-f5d71dac0bcb.

For example mine:

   Power Setting GUID: aded5e82-b909-4619-9949-f5d71dac0bcb  (Display brightness)
      Minimum Possible Setting: 0x00000000
      Maximum Possible Setting: 0x00000064
      Possible Settings increment: 0x00000001
      Possible Settings units: %
    Current AC Power Setting Index: 0x00000046
    Current DC Power Setting Index: 0x00000032

The value denotes the percentage (%). The increment can be done by 1% (as you can see).

There is even MSDN page about the brightness

Diathesis answered 15/5, 2019 at 12:54 Comment(12)
I really appreciate this response, but I know how to adjust brightness from CMD already. My problem is with obtaining the brightness value BEFORE it is changed.Mortality
After messing around with it to see what I can get, I still don't understand how it can get me the current screen brightness. Decoding the decimal values only gets me random characters.Mortality
@TheATLASCGZ now I don't understand you. For example: 0x00000064 is a hexadecimal number which means the maximum is 64%. My AC PowerSettings is at 46% and DC is at 32%. Note: the maximum is not always 100%Diathesis
Quick question: When I have the brightness manually set to anything but 100% the AC value (the only one that changes for me) is set to 0x00000000. So what now?Mortality
@TheATLASCGZ it is internal laptop screen or it is an external one?Diathesis
Internal @DiathesisMortality
@TheATLASCGZ That is weird maybe your power management is somehow corrupted? Did you check it via GUI - power management if you change the scheme there what happens?Diathesis
No change even though I modified the AC valueMortality
let's discuss this on discord instead. @Diathesis My username is NotTheATLAS#3239Mortality
@TheATLASCGZ I don't do discord. There is a chat on SO so you can start chat and post link here.Diathesis
The command doesn't work on my machines. Tried on 2 different laptops. The values get updated when I check with powercfg /q but I don't see screen brightness getting updated. tried both setdcvalueindex, and setacvalueindexAnselme
@SahilSingh sorry to hear that. I have tested it on my HP notebook back then on Windows 10 and it worked. Maybe you have a driver issue or perhaps some settings (like powersavings) do interfere.Diathesis
B
12

Query screen brightness

powershell -Command "Get-Ciminstance -Namespace root/WMI -ClassName WmiMonitorBrightness | Select -ExpandProperty "CurrentBrightness""

Change screen brightness

powershell -Command "(Get-WmiObject -Namespace root/WMI -Class WmiMonitorBrightnessMethods).WmiSetBrightness(1,<YOUR_BRIGHTNESS_INTEGER>)"
Beeswax answered 1/10, 2020 at 6:33 Comment(0)
D
7

You were close. Here is how you do it.

The format of powercfg is:

POWERCFG -SETDCVALUEINDEX <SCHEME_GUID> <SUBGROUP_GUID> <SETTING_GUID> value

To find out your information:

For <SCHEME_GUID>:

powercfg /q | findstr Scheme
Power Scheme GUID: a3e508ca-5ab1-4c55-bee1-9edfb71ba0a4  (HP Optimized (recommended))

For <SUBGROUP_GUID> and <SETTING_GUID>:

powercfg /q | findstr Display
  Subgroup GUID: 7516b95f-f776-4464-8c53-06167f40ca19  (Display)
    Power Setting GUID: aded5e82-b909-4619-9949-f5d31dac0bcb  (Display brightness)

Now with the GUID values and brightness in percentage - lets say 23% - like this:

powercfg -SetDcValueIndex a3e508ca-5ab1-4c55-bee1-9edfb71ba0a4 7516b95f-f776-4464-8c53-06167f40ca19 aded5e82-b909-4619-9949-f5d31dac0bcb 23

Edit: To view current britness level:

Check your current settings with the GUID: aded5e82-b909-4619-9949-f5d71dac0bcb

Just let the powercfg /q > current_settings.txt. Will save the output to current_settings.txt file and there search for the aded5e82-b909-4619-9949-f5d71dac0bcb.

For example mine:

   Power Setting GUID: aded5e82-b909-4619-9949-f5d71dac0bcb  (Display brightness)
      Minimum Possible Setting: 0x00000000
      Maximum Possible Setting: 0x00000064
      Possible Settings increment: 0x00000001
      Possible Settings units: %
    Current AC Power Setting Index: 0x00000046
    Current DC Power Setting Index: 0x00000032

The value denotes the percentage (%). The increment can be done by 1% (as you can see).

There is even MSDN page about the brightness

Diathesis answered 15/5, 2019 at 12:54 Comment(12)
I really appreciate this response, but I know how to adjust brightness from CMD already. My problem is with obtaining the brightness value BEFORE it is changed.Mortality
After messing around with it to see what I can get, I still don't understand how it can get me the current screen brightness. Decoding the decimal values only gets me random characters.Mortality
@TheATLASCGZ now I don't understand you. For example: 0x00000064 is a hexadecimal number which means the maximum is 64%. My AC PowerSettings is at 46% and DC is at 32%. Note: the maximum is not always 100%Diathesis
Quick question: When I have the brightness manually set to anything but 100% the AC value (the only one that changes for me) is set to 0x00000000. So what now?Mortality
@TheATLASCGZ it is internal laptop screen or it is an external one?Diathesis
Internal @DiathesisMortality
@TheATLASCGZ That is weird maybe your power management is somehow corrupted? Did you check it via GUI - power management if you change the scheme there what happens?Diathesis
No change even though I modified the AC valueMortality
let's discuss this on discord instead. @Diathesis My username is NotTheATLAS#3239Mortality
@TheATLASCGZ I don't do discord. There is a chat on SO so you can start chat and post link here.Diathesis
The command doesn't work on my machines. Tried on 2 different laptops. The values get updated when I check with powercfg /q but I don't see screen brightness getting updated. tried both setdcvalueindex, and setacvalueindexAnselme
@SahilSingh sorry to hear that. I have tested it on my HP notebook back then on Windows 10 and it worked. Maybe you have a driver issue or perhaps some settings (like powersavings) do interfere.Diathesis
G
1

If you'd prefer cmd.exe rather than PowerShell here's an example how you can successfully do it:

wmic /namespace:\\root\wmi ^
  path WmiMonitorBrightnessMethods ^
  where active=true ^
  call WmiSetBrightness Brightness=70 Timeout=0

See the answer at: https://mcmap.net/q/1476027/-how-to-pass-wmic-parameters-for-wmisetbrightness

Here's a brightness.bat script (Gist) I use to set the brightness using wmic and ddm on my laptop and monitors respectively (depending on the time of the day): https://gist.github.com/rwp0/fb40b2787207ec2d32056a080d144fa0

Goldstein answered 29/8, 2024 at 13:22 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.