Screen Dimming

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Luke Rawlins Luke Rawlins 2 years, 1 month ago.

  • Author
    Posts
  • #19525
    Profile photo of Luke Rawlins
    Luke Rawlins
    Participant

    I'm writing a script that does some basic set up of computers that come into my office before sending them out for deployment. One of the setting changes that I'm having trouble with is the timing on screen dimming for laptops. I found this function somewhere on the Hey scripting guy forum to return all the guid's in the currently active power scheme.

    Function Get-PowerSettings{
    $plan = Get-WmiObject -Class win32_powerplan -Namespace root\cimv2\power -Filter "isActive='true'"
    $regex = [regex]"{(.*?)}$"
    $planGuid = $regex.Match($plan.instanceID.Tostring()).groups[1].value
    } 
    

    I don't know how the regular expression above works but I can see that it does because

    powercfg -query $planGuid 

    returns a complete list of power settings for the currently active scheme. Thanks Scripting Guy! What I'm trying to do is pull one particular setting from the list and change the time frame for dimming the screen when under battery power, and ac power. Piping that command to Get-Member tells me that the only property I can select is length so I'm not sure how to isolate the particular setting I need, which is "dim display after".

    Basically here is how I change the other power settings.

    powercfg -change -monitor-timeout-ac 30
    powercfg -change -standby-timeout-ac 0
    

    Is there a way that is this easy to get the dim time settings as well, and I just haven't found it yet?

    Thanks

  • #19526
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    I don't seem to have this setting on my Windows 8.1 PC, but it's probably because this is a desktop without an integrated display (no dimming). Try this:

    $numberOfSeconds = 60
    powercfg /SETACVALUEINDEX $planguid SUB_VIDEO VIDEODIM $numberOfSeconds
    

    That would be for AC. For DC, it's just /SETDCVALUEINDEX.

    Using powercfg is a bit tricky; it's an old command-line tool with somewhat obscure syntax (some GUIDs, some aliases, not all documented very well.)

  • #19554
    Profile photo of Luke Rawlins
    Luke Rawlins
    Participant

    Thanks Dave,

    I'll give that a shot and let you know if it works.

You must be logged in to reply to this topic.