Compare commits
2 Commits
81a6bda175
...
080d0e5f1c
Author | SHA1 | Date | |
---|---|---|---|
080d0e5f1c | |||
89350ee4e2 |
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# How to run
|
||||||
|
Change PCIe paths in file
|
||||||
|
Execute switchGPU.ps1 in powershell
|
@ -1,2 +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 }
|
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
|
pnputil /disable-device "PCI\VEN_1002&DEV_1681&SUBSYS_380117AA&REV_C1\4&33381BD1&0&0041" #disable iGPU
|
@ -1,2 +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 }
|
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
|
pnputil /enable-device "PCI\VEN_1002&DEV_1681&SUBSYS_380117AA&REV_C1\4&33381BD1&0&0041" #enable iGPU
|
117
switchGPU.ps1
117
switchGPU.ps1
@ -1,57 +1,60 @@
|
|||||||
param([String]$working=$pwd, [String]$desktop = [Environment]::GetFolderPath("Desktop"))
|
param([String]$working=$pwd, [String]$desktop = [Environment]::GetFolderPath("Desktop"))
|
||||||
$folderPath = "C:\.gpu"
|
$iGPUpci = "PCI\VEN_1002&DEV_1681&SUBSYS_380117AA&REV_C1\4&33381BD1&0&0041"
|
||||||
$gpuTask = Join-Path $working GPU.xml
|
$dGPUpci = "PCI\VEN_10DE&DEV_1B80&SUBSYS_85AA1043&REV_A1\6&5c8cf2c&0&00080019"
|
||||||
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 }
|
|
||||||
|
$folderPath = "C:\.gpu" #do not change unless you change it in GPU.xml as well
|
||||||
$scriptOld = Join-Path $working "*"
|
$gpuTask = Join-Path $working GPU.xml #just do not change
|
||||||
$linkEnableOrig = Join-Path $folderPath "enableigpu.ps1"
|
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 }
|
||||||
$linkEnableDesk = Join-Path $desktop "Enable-iGPU"
|
|
||||||
$linkDisableOrig = Join-Path $folderPath "disableigpu.ps1"
|
$scriptOld = Join-Path $working "*"
|
||||||
$linkDisableDesk = Join-Path $desktop "Disable-iGPU"
|
$linkEnableOrig = Join-Path $folderPath "enableigpu.ps1"
|
||||||
Write-Output "Testing if files exist"
|
$linkEnableDesk = Join-Path $desktop "Enable-iGPU"
|
||||||
if(-Not (Test-Path $folderPath)){
|
$linkDisableOrig = Join-Path $folderPath "disableigpu.ps1"
|
||||||
Write-Output "Creating Directory $folderPath"
|
$linkDisableDesk = Join-Path $desktop "Disable-iGPU"
|
||||||
New-Item $folderPath -Type Directory
|
Write-Output "Testing if files exist"
|
||||||
attrib +h $folderPath
|
if(-Not (Test-Path $folderPath)){
|
||||||
Copy-Item $scriptOld $folderPath
|
Write-Output "Creating Directory $folderPath"
|
||||||
|
New-Item $folderPath -Type Directory
|
||||||
New-Item -ItemType SymbolicLink -Path $linkEnableDesk -Target $linkEnableOrig
|
attrib +h $folderPath
|
||||||
New-Item -ItemType SymbolicLink -Path $linkDisableDesk -Target $linkDisableOrig
|
Copy-Item $scriptOld $folderPath
|
||||||
}
|
|
||||||
|
New-Item -ItemType SymbolicLink -Path $linkEnableDesk -Target $linkEnableOrig
|
||||||
|
New-Item -ItemType SymbolicLink -Path $linkDisableDesk -Target $linkDisableOrig
|
||||||
Write-Output "Checking if task already exists"
|
}
|
||||||
if(Get-ScheduledTask | Where-Object{$_.TaskName -eq "GPU"})
|
|
||||||
{
|
|
||||||
Write-Output "Task exists"
|
Write-Output "Checking if task already exists"
|
||||||
}else
|
if(Get-ScheduledTask | Where-Object{$_.TaskName -eq "GPU"})
|
||||||
{
|
{
|
||||||
Register-ScheduledTask -TaskName "GPU" -Xml (Get-Content $gpuTask | Out-String)
|
Write-Output "Task exists"
|
||||||
}
|
}else
|
||||||
|
{
|
||||||
|
Register-ScheduledTask -TaskName "GPU" -Xml (Get-Content $gpuTask | Out-String)
|
||||||
Write-Output "Waiting 5 Seconds"
|
}
|
||||||
Start-Sleep 5
|
|
||||||
if(Get-PnpDevice | Where-Object{$_.InstanceId -eq "PCI\VEN_10DE&DEV_1B80&SUBSYS_85AA1043&REV_A1\6&5c8cf2c&0&00080019"} | Where-Object{$_.Status -eq "OK"})
|
|
||||||
{
|
Write-Output "Waiting 5 Seconds"
|
||||||
Write-Output "dGPU plugged in"
|
Start-Sleep 5
|
||||||
if(Get-PnpDevice | Where-Object{$_.InstanceId -eq "PCI\VEN_1002&DEV_1681&SUBSYS_380117AA&REV_C1\4&33381BD1&0&0041"} | Where-Object{$_.Status -eq "OK"})
|
if(Get-PnpDevice | Where-Object{$_.InstanceId -eq $dGPUpci} | Where-Object{$_.Status -eq "OK"})
|
||||||
{
|
{
|
||||||
Write-Output "Disabling iGPU"
|
Write-Output "dGPU plugged in"
|
||||||
pnputil /disable-device "PCI\VEN_1002&DEV_1681&SUBSYS_380117AA&REV_C1\4&33381BD1&0&0041" #disable iGPU
|
if(Get-PnpDevice | Where-Object{$_.InstanceId -eq $iGPUpci} | Where-Object{$_.Status -eq "OK"})
|
||||||
}else
|
{
|
||||||
{
|
Write-Output "Disabling iGPU"
|
||||||
Write-Output "iGPU already disabled"
|
pnputil /disable-device $iGPUpci #disable iGPU
|
||||||
}
|
}else
|
||||||
}else
|
{
|
||||||
{
|
Write-Output "iGPU already disabled"
|
||||||
Write-Output "dGPU not plugged in"
|
}
|
||||||
if(Get-PnpDevice | Where-Object{$_.InstanceId -eq "PCI\VEN_1002&DEV_1681&SUBSYS_380117AA&REV_C1\4&33381BD1&0&0041"} | Where-Object{$_.Status -eq "OK"})
|
}else
|
||||||
{
|
{
|
||||||
Write-Output "iGPU already enabled"
|
Write-Output "dGPU not plugged in"
|
||||||
}else
|
if(Get-PnpDevice | Where-Object{$_.InstanceId -eq $iGPUpci} | Where-Object{$_.Status -eq "OK"})
|
||||||
{
|
{
|
||||||
Write-Output "Enabling iGPU"
|
Write-Output "iGPU already enabled"
|
||||||
pnputil /enable-device "PCI\VEN_1002&DEV_1681&SUBSYS_380117AA&REV_C1\4&33381BD1&0&0041" #enable iGPU
|
}else
|
||||||
}
|
{
|
||||||
}
|
Write-Output "Enabling iGPU"
|
||||||
|
pnputil /enable-device $iGPUpci #enable iGPU
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user