tag:blogger.com,1999:blog-318146684371374891.post5381157771690592420..comments2023-06-09T12:36:06.820+01:00Comments on Nasher The Intrepidis: Keep the monitor display brightness the same when the power source is changed to battery/chargingIntrepidishttp://www.blogger.com/profile/04311866951614945265noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-318146684371374891.post-81825101360535967462022-11-02T08:26:59.627+00:002022-11-02T08:26:59.627+00:00Thanks for all the tweaks. I wonder whether you st...Thanks for all the tweaks. I wonder whether you still use this script?Intrepidishttps://www.blogger.com/profile/04311866951614945265noreply@blogger.comtag:blogger.com,1999:blog-318146684371374891.post-36843082958122128422018-05-22T17:12:17.739+01:002018-05-22T17:12:17.739+01:00Thank you, it works after few tweaks.
1) Powersh...Thank you, it works after few tweaks.<br /><br /><br />1) Powershell 5.0 is needed because command (New-TemporaryFile) is not supported in 3.0. <br />You can eventually change this command to powershell 3.0 variant.<br /><br />2) "IF" condition should be removed from "# Register the event handler" code<br /><br />from:<br /><br /># Register the event handler.<br />Register-CimIndicationEvent -Query $powerEventQuery -SourceIdentifier $eventId -Action {<br /> Stop-Job -Name $global:jobId<br /> $currentBrightness = Get-MyBrightness<br /> $savedBrightness = Get-Content -Path $global:savedBrightnessFile<br /> if ($currentBrightness -ne $savedBrightness) {<br /> Set-MyBrightness($savedBrightness)<br /> }<br />} | Out-Null<br /><br />to:<br /><br /># Register the event handler.<br />Register-CimIndicationEvent -Query $powerEventQuery -SourceIdentifier $eventId -Action {<br /> Stop-Job -Name $global:jobId<br /> $currentBrightness = Get-MyBrightness<br /> $savedBrightness = Get-Content -Path $global:savedBrightnessFile<br /> Set-MyBrightness($savedBrightness)<br />} | Out-Null<br /><br /><br />3) "-noexit" parameter should be added to Task Scheduler action to keep the script running:<br />-noexit -ExecutionPolicy Bypass -File "C:\Battery power display brightness.ps1"<br /><br />4) It may be needed to add another trigger for computer wake up if you use sleep function:<br />https://social.technet.microsoft.com/Forums/windows/en-US/0462579d-780a-460a-befd-90f755e902aa/how-to-schedule-a-task-on-resume-from-sleep?forum=itprovistaapps<br /><br />5) It may be needed to modify user account in Task properties after importMarekhttps://www.blogger.com/profile/07298675939333688516noreply@blogger.com