I purchased a gaming laptop nearly eighteen months ago and I was so happy and hyped about it until it started to overheat and give me bluescreens of death. I searched a lot on google and Acer’s community for a fix, but unfortunately, there was none. After so many attempts to fix it, I figured out that the discrete Graphics Card (Nvidia 1660Ti) was causing the problem whenever the laptop was running on Battery. Therefore, I decided to disable the GPU whenever I was using the laptop on battery, but it was taking a lot of my time (probably 15 seconds every time) and if you know me you’ll probably already know that I don’t love wasting time(😁). So I figured out one way to disable it automatically whenever I remove the charger and enable it otherwise.
What do you need to do?
1. Write two simple PowerShell scripts to disable and enable your GPU(or any other device)
2. Find the event logged when you plug and unplug your power adapter using Windows Event Viewer.
3. Attach a task to each Event using TaskScheduler
Step One - Writing the Script
No need to worry, the script is already there all you have to do is replace the InstanceID with your GPU’s(or any other devices) Instance ID without removing the quotations.
Script for Disabling :
pnputil /disable-device "InstanceID"
Script for Enabling:
pnputil /enable-device "InstanceID"
How to get the Devices Instance ID? Easy just follow the steps:
press Windows Key + R to open Run.
select the device you want (for me it’s Nvidia Geforce GTX 1660Ti)
head to the Details section and choose Device Instance Path and copy and paste it into the scripts.
save both scripts with .ps1 extension (name it whatever you want here I’m naming them disable.ps1 and enable.ps1)
Now your Scripts are ready. Next, we are going to Log the power plug and unplug events.
Step Two - Logging the event
Now, we need to know which event is being logged when we plug and unplug the charger. For that, we have to head to the Windows event viewer. Follow me:
- open Run again, press Windows Key + R
- type
eventvwr.msc
and press enter - head to windows logs -> System
- now plug and unplug your charger multiple times (two to three is enough) to see the event that’s being logged.
refresh the list by pressing F5 and you’ll see multiple events with the “Kernel-Power” source.
there you’ll see something like
AcOnline true
Or
AcOnline false
The first one is for the event that’s raised when you plug in the power and the other one is for unplugging the power (if yours is any of the two don’t worry the other one is the event below or above it).
Now we have found the event, the next step is to attach a task to each of the events. Here, I'm only going to attach a task to the unplugging event, but you’ll need to do it for the plugging too. Don’t panic, it’s the same step except that you have to attach the enable script to the plugging task instead of the disable script.
Step Three - Attaching a Task to the Events
After finding the events simply right-click on one of the events ( in my case it’s the unplug event) and choose “Attach Task to This Event” and follow the upcoming steps:
- Give the task any name you wish (I’m choosing DisableGPU) and press next
Type
Powershell.exe
in the “Program/Script” filedtype
-ExecutionPolicy Bypass -FILE "E:\disable.ps1"
in the “Add arguments” field with
E:\disable.ps1 replaced by your path to the disable script and press click next.
-
check the “Open the properties Dialogue for this when I click finish” and click finish
Now make sure you modify the task properties as Screenshots below:
Hooray 🎉🎉🎉, now your laptop will automatically disable the GPU whenever you remove the power cord but don’t forget you need to automatically turn it back on by attaching the plug event to a task that runs enable GPU script.
Top comments (10)
The game will be challenging to play with your settings. It is, however, dependant on the game. It's possible that the game isn't working correctly on your video graphics card. Anyway, have you thought of getting an Nvidia GTX? Yes, I am aware that prices are at an all-time low right now. There are, however, some excellent models available at a reasonable price. Yesterday, I spotted the GTX 1660, which is the most popular because of its power for the price. There are various models for 1660. If you're considering buying a 1660 Ti or a 1660 Super, see this post quickreviewshow.com/1660-ti-vs-166... I sincerely hope I was able to aid someone!
That's a great suggestion for graphic cards thanks for sharing!
Hi @muhammedziyad
Thank you very much for this great tip! It works really well when plugging and unplugging the charger. But it does not work on windows startup because the event is not fired.
Do you now any workaround to check the status of kernel power source on windows startup and if AcOnline is false, run the script to deactivate GPU, and if AcOnline is true, run the script to activate GPU?
Thanks @muhammedziyad !
Best regards!
You can use custom xml filter for task scheduler, where
Data='true' means laptop running on Ac
Data='false' running on battery
Dont know if I did it correctly because when my laptop is unplugged the dedicated gpu is still used, and when its plugged in, the dedicated gpu isnt enabled, ran the script normally using powershell and it only works when ran as administrator
Hello, strangely this doesn't work 100% of the time for me. With device manager open, disconnecting and reconnecting the power cable a few times, the dGPU turns off and on correctly, but every couple of times I connect it to power it says I can disable the dGPU in the top bar, despite it having the disabled icon on the dGPU.
Well done, a very useful article
Is there any method to hide the powershell window while running?
I don't think it worked for me, how can I delete the tasks so that the powershell window stops apearing?
Thanks!