From 81a6bda1759fe9a8a91d10c5385d94d059a73a2d Mon Sep 17 00:00:00 2001 From: unknown <13404778+C9Glax@users.noreply.github.com> Date: Fri, 31 Mar 2023 15:17:47 +0200 Subject: [PATCH] Added shortcuts to enable/disable iGPU manually on desktop. --- disableigpu.ps1 | 2 ++ enableigpu.ps1 | 2 ++ switchGPU.ps1 | 19 +++++++++++-------- 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 disableigpu.ps1 create mode 100644 enableigpu.ps1 diff --git a/disableigpu.ps1 b/disableigpu.ps1 new file mode 100644 index 0000000..9e75d05 --- /dev/null +++ b/disableigpu.ps1 @@ -0,0 +1,2 @@ +if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit } +pnputil /disable-device "PCI\VEN_1002&DEV_1681&SUBSYS_380117AA&REV_C1\4&33381BD1&0&0041" #disable iGPU \ No newline at end of file diff --git a/enableigpu.ps1 b/enableigpu.ps1 new file mode 100644 index 0000000..facccc1 --- /dev/null +++ b/enableigpu.ps1 @@ -0,0 +1,2 @@ +if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit } +pnputil /enable-device "PCI\VEN_1002&DEV_1681&SUBSYS_380117AA&REV_C1\4&33381BD1&0&0041" #enable iGPU \ No newline at end of file diff --git a/switchGPU.ps1 b/switchGPU.ps1 index 912e061..83bae9e 100644 --- a/switchGPU.ps1 +++ b/switchGPU.ps1 @@ -1,19 +1,22 @@ -param([String]$working=$pwd) +param([String]$working=$pwd, [String]$desktop = [Environment]::GetFolderPath("Desktop")) $folderPath = "C:\.gpu" $gpuTask = Join-Path $working GPU.xml -if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" -working $pwd" -Verb RunAs; exit } +if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" -working $pwd -desktop $desktop" -Verb RunAs; exit } +$scriptOld = Join-Path $working "*" +$linkEnableOrig = Join-Path $folderPath "enableigpu.ps1" +$linkEnableDesk = Join-Path $desktop "Enable-iGPU" +$linkDisableOrig = Join-Path $folderPath "disableigpu.ps1" +$linkDisableDesk = Join-Path $desktop "Disable-iGPU" Write-Output "Testing if files exist" if(-Not (Test-Path $folderPath)){ Write-Output "Creating Directory $folderPath" New-Item $folderPath -Type Directory attrib +h $folderPath -} -$scriptOld = Join-Path $working "switchGPU.ps1" -$scriptNew = Join-Path $folderPath "switchGPU.ps1" -if(-Not (Test-Path $scriptNew)){ - Write-Output "Copying script to $folderPath" - Copy-Item $scriptOld $scriptNew + Copy-Item $scriptOld $folderPath + + New-Item -ItemType SymbolicLink -Path $linkEnableDesk -Target $linkEnableOrig + New-Item -ItemType SymbolicLink -Path $linkDisableDesk -Target $linkDisableOrig }