If you’re experiencing issues with the Night Light feature in Windows 11, you’re not alone. Many users have reported that their Night Light does not turn on or off automatically based on their set schedule. Instead of waiting for Microsoft to roll out a fix, I decided to create a workaround using a little PowerShell scripting. Here’s a step-by-step guide on how to automate this process.
Understanding the Problem
The Night Light feature is meant to adjust your screen’s color temperature to reduce eye strain, especially during nighttime. However, when you set a custom schedule for the Night Light feature, it often doesn’t activate or deactivate as expected. You may find that it remains on when it should be off or vice versa. This inconvenience can be frustrating, especially when you rely on this feature for your evening routine.
Tools You’ll Need
To tackle this issue, you will need:
- NirCmd: A helpful utility that can help hide the PowerShell window for a smoother experience. You can download it from NirSoft.
- PowerShell Module: The file
Switch-NightLight.psm1
from Nathan’s GitHub repository. You can find it here. Click on “Raw” to save the link as a file.
Setting Up Your Fix
- Create a Folder: Start by creating a new folder on your computer for your scripts. For example, you can create a folder named “Scripts” in your Documents.
- Extract NirCmd: Download and extract the NirCmd zip file. Place the
NirCmd.exe
inside the “Scripts” folder you just created. - Organize Your Files: Within the “Scripts” folder, create a new subfolder named “Files”. Save the
Switch-NightLight.psm1
file you downloaded into this “Files” folder. - Create a PowerShell Script: In your main “Scripts” folder, create a new PowerShell file:
- Open Notepad and paste the following code:
cd $PSScriptRoot
Import-Module ".\Files\Switch-NightLight.psm1"
$currentHour = (Get-Date).Hour
$turnOn = 21 # Set your preferred hour in 24-hour format
$turnOff = 6 # Set your preferred hour in 24-hour format
if ($currentHour -ge $turnOn -or $currentHour -lt $turnOff) {
Enable-NightLight
} else {
Disable-NightLight
}
- Customize
$turnOn
and$turnOff
to your preferred hours. For instance, if you want Night Light to activate at 9 PM and deactivate at 6 AM, keep the settings as shown.
- Save the Script: Save this file with the name
NightLightFix.ps1
, ensuring the file extension is .ps1 (PowerShell script).
Automate the Script with Task Scheduler
Lastly, to automate the script:
- Open Task Scheduler (search in the Start Menu).
- Click on Create Task on the right side.
- Give your task a meaningful name.
- Set the trigger based on your schedule preferences, ensuring it runs at the times that suit your Night Light preferences.
After completing these steps, your Night Light feature should now function according to your specified schedule, providing a more seamless experience on your Windows 11 device. This workaround is a great way to bypass the ongoing issues while waiting for an official update from Microsoft. Happy computing!
Add comment