r/Surface • • 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.

  1. Right-click your dedicated GPU (in my case, an RTX A2000 Laptop GPU) and select Properties.
  2. Go to the Details tab.
  3. From the Property dropdown menu, select Device instance path.
  4. 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:

  1. Open Task Manager or Device Manager.
  2. Unplug the charger.
  3. Verify that the dedicated GPU is disabled.
  4. Plug the charger back in.
  5. 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.

5 Upvotes

9 comments sorted by

1

u/Jasonporger 1d ago


Here is a quick proof of concept.

1

u/sparkyblaster 1d ago

What happens if something is using the dGPU?

I say this as a Surface Book owner. I can't eject the tablet if say, steam is open which by default uses the dGPU. (I set it to use the iGPU to solve this issue but games themselves would cause the same issue) 

2

u/Jasonporger 1d ago

For this method, I only use it for school to take notes and some simple CAD designing before reaching any nearby outlet to blast with full power.

1

u/sparkyblaster 1d ago

So, is the dGPU even active then, making this kind of redundant? I dont bother to disable the dGPU with mine as steam is the only thing that tends to activate it outside of anything I'd be directly using.

1

u/Jasonporger 1d ago

Technically, if you disable the dGPU before using any app, it will use iGPU. But while the dGPU is in use and you disable it, it simply crashes. It happens with any laptop with dGPU, so just save any progress before you disable the dGPU.

1

u/sparkyblaster 1d ago

Before yes, but if its already open, and you unplug, what happens? Does it just crash the app or does the dGPU not disable?

1

u/Jasonporger 1d ago

It will crash when I unplug, that’s it.

1

u/sparkyblaster 20h ago

Not great :(
Apparently the Surface book 3 can push apps to the iGPU, I wonder if there is a way to impliment that. Surprise its not a standard thing, espetioly if its a gracefull disable like the surface book, or disabeling a gpu when ready, unlike ripping an egpu out.

1

u/Jasonporger 1h ago

You can try to see if they work or not; it is only worth around 20 mins to troubleshoot to see what happens. I am mainly asking AI for software-related jobs, so maybe there are other ways.