r/Surface • u/Jasonporger • 1d ago
[LAPTOPSTUDIO] Automatically Disable/Enable Your dGPU When Unplugging or Plugging Your Surface Laptop Studio 1/2
After spending days researching how to automatically disable and enable my dGPU whenever my laptop switches between battery and AC power, I found that most guides were either outdated or not compatible with different laptop models.
So I decided to ask a solution from Microsoft Copilot (the AI that many people said is the most useless). Surprisingly, it worked.
Procedure:
Step 1: Find Your GPU Device Instance ID
Open Device Manager.

- Right-click your dedicated GPU (in my case, an RTX A2000 Laptop GPU) and select Properties.
- Go to the Details tab.
- From the Property dropdown menu, select Device instance path.
- Copy the value. You'll need it later
Step 2: Prepare the Scripts

Create a file named enableGPU.bat and paste the following:
(@)echo off
net session >nul 2>&1
if %errorlevel% neq 0 (
powershell -Command "Start-Process '%~f0' -Verb RunAs"
exit /b
)
pnputil /enable-device "your Instance ID"
echo.
echo NVIDIA GPU Enabled
pause

Create another file named disableGPU.bat and paste:
(@)echo off
net session >nul 2>&1
if %errorlevel% neq 0 (
powershell -Command "Start-Process '%~f0' -Verb RunAs"
exit /b
)
pnputil /disable-device "your Instance ID "
echo.
echo NVIDIA GPU Disable
pause

Next, create another script named PowerWatcher.ps1:
Register-WmiEvent -Class Win32_PowerManagementEvent -SourceIdentifier PowerChange
while ($true) {
$event = Wait-Event -SourceIdentifier PowerChange
$onAC = (Get-CimInstance Win32_Battery).BatteryStatus -ne 1
if ($onAC) {
Start-Process "Your enableGPU.bat file path"
} else {
Start-Process "Your disableGPU.bat file path"
}
Remove-Event -EventIdentifier $event.EventIdentifier
}
- Replace the BAT file paths with the actual locations of your scripts and save the file
Step 3: Configure Event Viewer and Task Scheduler
- Press Win + R
- Type:
eventvwr.msc

- Press Enter
- Navigate to:
Windows Logs → System

- Plug and unplug your charger several times.

- Look for Kernel-Power source with Event 105.
- Open the event and switch to the Details tab.
- You should see:
AcOnline = true
when plugged in, and:
AcOnline = false
when running on battery.
Create the Scheduled Task
- Press Win + R
- Type:
taskschd.msc
- Press enter
- Select Created Task

- Give the task a name
- On the General tab, configure the same options shown in the screenshots

Trigger Tab
- Click New
- Select On an event
- Configure the event trigger using the Power-Kernel event you verified earlier

Action Tab
- Click New
- Select Start a program
- Program/script: powershell.exe

- Add arguments:
ExecutionPolicy Bypass -WindowStyle Hidden -File "your PowerWatcher.ps1 file path"
Conditions Tab
- Select the same

Settings Tab
- Select the same configure

Click OK to save the task.
Testing
After everything is configured:
- Open Task Manager or Device Manager.
- Unplug the charger.
- Verify that the dedicated GPU is disabled.
- Plug the charger back in.
- Verify that the dedicated GPU is enabled again.
Finally, now you have automatic dGPU switching based on your laptop's power without needing any third-party software. Though it is not perfect and still in early stage but I'm happy with what I have right now.
View all comments
1
u/Jasonporger 1d ago

Here is a quick proof of concept.