Sign in to follow this  
Followers 0
stampy

Setting power scheme.

8 posts in this topic

I'm trying to create a setup script for many different computers. One thing it will need to do is to set the power settings to not turn off the monitor or hard drives.

I've succeeded in setting the name of the scheme but nothing seems to actually change the monitor/hdd settings.

I've found a few examples using powercfg.exe. However some of the systems are Windows XP and some are Windows 2k. Powercfg.exe does not work on 2k.

I found this link:

http://www.autoitscript.com/forum/index.php?showtopic=10218&st=0&p=71350&hl=setting%20power%20schemes&fromsearch=1&#entry71350

I tried this and it still doesn't change the settings on 2k (I haven't tried on xp yet). When I change to the needed settings. Then export the reg file. Then change them to something else. Then import the reg file... it doesn't change the settings either. Am I looking in the wrong area? How can I accomplish this simple task in Windows 2k?

Any advice is greatly appreciated.

SetUserPowercfg()


Func SetUserPowercfg()
    RegWrite("HKEY_CURRENT_USER\Control Panel\PowerCfg", "CurrentPowerPolicy", "REG_SZ", "2")
    If @error Then
        Return 0
    Else
        Return 1
    EndIf
    RegWrite('HKEY_CURRENT_USER\Control Panel\PowerCfg\PowerPolicies\2', 'Policies', 'REG_BINARY', _
            '0100000000000000010000000000000000000000000000000000' & _
            '000000000000000000003232000001000000010000006c000000' & _
            '43003a00000000002c01000000000000580200000000646464646500')
    If @error Then
        Return 0
    Else
        Return 1
    EndIf
EndFunc   ;==>SetUserPowercfg

Share this post


Link to post
Share on other sites



I don't know if you just don't have access to the registry key or not, but if you do, here is a page to check out.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I don't know if you just don't have access to the registry key or not, but if you do, here is a page to check out.

That would be nice. Powercfg.exe does everything I would need it to... except work with windows 2k :) >>> http://support.microsoft.com/kb/888742

Edit: And yes, full control, local computers with administrator priv.

Edited by stampy

Share this post


Link to post
Share on other sites

Oops. Sorry. Didn't see that part about win2k.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Oops. Sorry. Didn't see that part about win2k.

Hi,

After your first regwrite you make a return. So your 2nd Regwrite isn't executed forever.

$var = SetUserPowercfg()

Func SetUserPowercfg()
$return = 0    
RegWrite("HKEY_CURRENT_USER\Control Panel\PowerCfg", "CurrentPowerPolicy", "REG_SZ", "0")
    If @error Then
        $return = 0
    Else
        $return = 2
    EndIf
    RegWrite('HKEY_CURRENT_USER\Control Panel\PowerCfg\PowerPolicies\2', 'Policies', 'REG_BINARY', _
            '0100000000000000010000000000000000000000000000000000' & _
            '000000000000000000003232000001000000010000006c000000' & _
            '43003a00000000002c01000000000000580200000000646464646500')
    If @error Then
        $return = $return + 4
    Else
        $return = $return + 8
    EndIf
    Return $return ; 10 -> no error, 4 -> Error 1st and 2nd regwrite, 8 -> error 1st .....
EndFunc   ;==>SetUserPowercfg

;-))

Stefan

Edited by 99ojo

Share this post


Link to post
Share on other sites

powercfg.exe should work on Win2k SP4.

Hi,

see here:

http://support.microsoft.com/kb/888742/en-us

;-))

Stefan

Share this post


Link to post
Share on other sites

Your right the error catch wouldn't allow the second one. I also saw that the current policy was being set wrong. However, turns out I pasted the wrong code. I changed it with no error catching to make sure I tested it right and the following didn't work either.

Func SetUserPowercfg2()
RegWrite("HKEY_CURRENT_USER\Control Panel\PowerCfg", "CurrentPowerPolicy", "REG_SZ", "2")
   
    RegWrite('HKEY_CURRENT_USER\Control Panel\PowerCfg\PowerPolicies\2', 'Policies', 'REG_BINARY', _
            '0100000000000000010000000000000000000000000000000000' & _
            '000000000000000000003232000001000000010000006c000000' & _
            '43003a00000000002c01000000000000580200000000646464646500')
    
    MsgBox(0,'','done')
EndFunc

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