stampy Posted September 30, 2009 Posted September 30, 2009 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
dantay9 Posted October 1, 2009 Posted October 1, 2009 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.
stampy Posted October 1, 2009 Author Posted October 1, 2009 (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/888742Edit: And yes, full control, local computers with administrator priv. Edited October 1, 2009 by stampy
99ojo Posted October 1, 2009 Posted October 1, 2009 (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 October 1, 2009 by 99ojo
Yashied Posted October 1, 2009 Posted October 1, 2009 powercfg.exe should work on Win2k SP4. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
99ojo Posted October 1, 2009 Posted October 1, 2009 powercfg.exe should work on Win2k SP4.Hi,see here:http://support.microsoft.com/kb/888742/en-us;-))Stefan
stampy Posted October 1, 2009 Author Posted October 1, 2009 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now