Guest User

Untitled

a guest
Dec 12th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <?php
  2.  
  3. $host = '10.0.0.10';
  4. $username = 'username';
  5. $password = 'password';
  6.  
  7. $WbemLocator = new COM ( "WbemScripting.SWbemLocator" );
  8. $objPwr = $WbemLocator->ConnectServer ( $host, 'root\cimv2power', $username, $password );
  9.  
  10. $PowerPlanInstanceID = '{8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c}'; //Performance
  11. $ACDC = 'AC';
  12. $InstansID = 'Microsoft:PowerSettingDataIndex\\'.$PowerPlanInstanceID.'\\'.$ACDC.'\\{3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e}'; //Turn off display after
  13.  
  14. // Change PowerSetting for "Turn off display after" from default 800 to 600
  15. $query = "Select * from Win32_PowerSettingDataIndex WHERE InstanceID = '$InstansID'";
  16. $PowerPlanSetting = $objPwr->ExecQuery ( $query );
  17. foreach ( $PowerPlanSetting as $Setting ) {
  18. $Setting->SettingIndexValue = '600';
  19. }
  20.  
  21. // Activating PowerPlan
  22. $PowerPlan = $objPwr->ExecQuery ( "Select * from Win32_PowerPlan WHERE ElementName = 'High performance'" );
  23. foreach ( $PowerPlan as $Plan ) {
  24. $Plan->Activate();
  25. }
  26.  
  27. // Check PowerSetting
  28. foreach ( $PowerPlanSetting as $Setting ) {
  29. echo $Setting->InstanceID . ' '. $Setting->SettingIndexValue;
  30. }
  31.  
  32. ?>
Add Comment
Please, Sign In to add comment