Sign in to follow this  
Followers 0
enggniteshgarg

Getting Power Settings

16 posts in this topic

Hi All,

I am new in Auto Script. I am trying to get powrsetting from a mchine through script. I have diffrent model of laptop and desktop form which i just want to pull power settings.

I tried pwercfg command line, but i don't know how to get curent user setting using this command and display in msgbox.

does someone has any idea.Thanks in advance

Share this post


Link to post
Share on other sites



powercfg -getactivescheme will return the currently active scheme in Vista and higher. In XP if you use powercfg -q it is listed in a table with the first entry being Name with the name of the scheme in use.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Hi, enggniteshgarg. It may also help us help you if you tell us a little bit more about what info you're trying to pull. As BrewMan mentioned, the powercfg command will pull most anything you want, but it can pull a LOT of data. Are you looking just for the active power scheme, like you would get with powercfg -L, or something more specific?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Thanks a lot for your answer. But I want to pull the information about Hibernet time, Power button action, Lid close action. I want to pull this value from machine using any command line or registry. Does someone has any idea.....?

BrewMan i tried powercfg -getactivescheme but its not helpful for me...................Do you know some other option

Thanks in advance..................

Share this post


Link to post
Share on other sites

Hi, enggniteshgarg. These are all registry settings, but they are Binary settings so a bit harder to ascertain. The entries are located in

HKCU\Control Panel\PowerCfg\GlobalPowerPolicy\Policies. For example, the option to "Ask me what to do" when the power button is pressed would be a value of:

01,00,00,00,00,00,00,00,03,00,00,00,08,00,00,00,00,00,00,00,03,\
  00,00,00,08,00,00,00,02,00,00,00,03,00,00,00,00,00,00,00,02,00,00,00,03,00,\
  00,00,00,00,00,00,02,00,00,00,01,00,00,00,00,00,00,00,02,00,00,00,01,00,00,\
  00,00,00,00,00,01,00,00,00,03,00,00,00,02,00,00,00,04,00,00,c0,01,00,00,00,\
  02,00,00,00,01,00,00,00,0a,00,00,00,00,00,00,00,03,00,00,00,01,00,01,00,01,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,02,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03,00,00,00,00,\
  00,16,00,00,00

Whereas the option to shutdown when the power button is pressed would be:

01,00,00,00,00,00,00,00,03,00,00,00,10,00,00,00,00,00,00,00,03,\
  00,00,00,10,00,00,00,02,00,00,00,03,00,00,00,00,00,00,00,02,00,00,00,03,00,\
  00,00,00,00,00,00,02,00,00,00,01,00,00,00,00,00,00,00,02,00,00,00,01,00,00,\
  00,00,00,00,00,01,00,00,00,03,00,00,00,02,00,00,00,04,00,00,c0,01,00,00,00,\
  02,00,00,00,01,00,00,00,0a,00,00,00,00,00,00,00,03,00,00,00,01,00,01,00,01,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,02,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03,00,00,00,00,\
  00,16,00,00,00

Notice the difference at character 38 on line 1, and character 10 on line 2.You might look at this (older) thread that talks about setting some of these properties, it may point you in the right direction.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Thanks a lot JLogan3o13 . How i will pull all information like sleep time, Lid action, power button action and hibernet option using this registry key?

Share this post


Link to post
Share on other sites

It is also in that same spot. This is what I would suggest:

1. Browse to this value in the registry and export it to a reg file.

2. Make the change you want manually.

3. Export the value again.

4. Use a tool such as WinMerge to show you exactly which bit has changed.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Can powercfg be used to set the Choose the sleep and display settings

I want them for a laptop set to Never for all the options with it plugged in so no sleep no turn off display etc

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

This might do what you're looking for, it's from Windows 7 but I'm not sure if all those settings apply to all versions of Windows.

-CHANGE, -X Modifies a setting value in the current power scheme.

Usage: POWERCFG -X <SETTING> <VALUE>

<SETTING> Specifies one of the following options:

-monitor-timeout-ac <minutes>

-monitor-timeout-dc <minutes>

-disk-timeout-ac <minutes>

-disk-timeout-dc <minutes>

-standby-timeout-ac <minutes>

-standby-timeout-dc <minutes>

-hibernate-timeout-ac <minutes>

-hibernate-timeout-dc <minutes>

Example:

POWERCFG -Change -monitor-timeout-ac 5

This would set the monitor idle timeout value to 5 minutes

when on AC power.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Yep similar to what i was working on

RunWait("powercfg.exe -change -monitor-timeout-ac 10000 ", @SW_HIDE)
RunWait("powercfg.exe -change -disk-timeout-ac minutes 10000 ", @SW_HIDE)
RunWait("powercfg.exe -change -standby-timeout-ac minutes 10000 ", @SW_HIDE)

But i have no idea to know whether it worked or not as i cant seem to find the settings to check lol

Share this post


Link to post
Share on other sites

Example of a policy

[HKEY_CURRENT_USERControl PanelPowerCfg]
"CurrentPowerPolicy"="0"

[HKEY_CURRENT_USERControl PanelPowerCfgGlobalPowerPolicy]
"Policies"=hex:01,00,00,00,00,00,00,00,03,00,00,00,10,00,00,00,00,00,00,00,03,
00,00,00,10,00,00,00,02,00,00,00,01,00,00,00,00,00,00,00,02,00,00,00,01,00,
00,00,00,00,00,00,00,00,00,00,01,00,00,00,00,00,00,80,00,00,00,00,01,00,00,
00,00,00,00,80,01,00,00,00,04,00,00,00,00,00,00,00,04,00,00,c0,03,00,00,00,
04,00,00,00,01,00,00,00,08,00,00,00,00,00,00,00,03,00,00,00,03,00,01,00,04,
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,02,00,00,00,
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03,00,00,00,00,
00,1f,6f,7e,58

[HKEY_CURRENT_USERControl PanelPowerCfgPowerPolicies0]
"Name"="On"
"Description"="This scheme is designed for maximum performance."
"Policies"=hex:01,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00,00,00,00,00,01,
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,32,32,02,02,04,00,00,00,04,00,
00,00,00,00,3a,77,2e,f2,07,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,
00,00,00,64,64,64,64,92,7c

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Yep similar to what i was working on

RunWait("powercfg.exe -change -monitor-timeout-ac 10000 ", @SW_HIDE)
RunWait("powercfg.exe -change -disk-timeout-ac minutes 10000 ", @SW_HIDE)
RunWait("powercfg.exe -change -standby-timeout-ac minutes 10000 ", @SW_HIDE)

But i have no idea to know whether it worked or not as i cant seem to find the settings to check lol

That doesn't work, but this does:

ShellExecuteWait('powercfg.exe', '-change -monitor-timeout-ac 100000')
ShellExecuteWait('powercfg.exe', '-change -disk-timeout-ac minutes 10000')
ShellExecuteWait('powercfg.exe', '-change -standby-timeout-ac minutes 10000')

EDIT: As a matter of fact only one setting worked as you can see from this pic.

post-68092-0-75958900-1353523627_thumb.p

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

So which one of these three work then?

ShellExecuteWait('powercfg.exe', '-change -monitor-timeout-ac 10000')
ShellExecuteWait('powercfg.exe', '-change -disk-timeout-ac minutes 10000')
ShellExecuteWait('powercfg.exe', '-change -standby-timeout-ac minutes 10000')
Edited by Chimaera

Share this post


Link to post
Share on other sites

So which one of these three work then?

-monitor-timeout-ac 10000')

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

These were what i was getting them from.

http://technet.microsoft.com/en-us/library/cc748940%28v=ws.10%29.aspx

- monitor-timeout-ac minutes

- monitor-timeout-dc minutes

- disk-timeout-ac minutes

- disk-timeout-dc minutes

- standby-timeout-ac minutes

- standby-timeout-dc minutes

- hibernate-timeout-ac minutes

- hibernate-timeout-dc minutes

I wonder if the minutes value is too large?

500 would be 8 hrs which would be plenty

Edited by Chimaera

Share this post


Link to post
Share on other sites

use the value "0" to disable it for this session

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0