-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddJavawPath.ps1
53 lines (46 loc) · 1.71 KB
/
AddJavawPath.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
### Updated (YYYY-MM-DD) 2021-05-22
### If you would like to add a launcher, or update existing ones with new paths, please submit proof/ref to the change.
# GpuPreference=
# 0=auto
# 1=PowerSave
# 2=HighPerf
$timeStamp = Get-Date -Format "yyyy-MM-dd_HH-mm"
if (test-path ".\backup") {
write-host "backup folder exists"
} else {
Write-Host "making backup folder"
mkdir .\backup
}
# Backup
write-host "`n"
Write-Host "backing up at $timestamp" -ForegroundColor Yellow
Invoke-Command {reg export 'HKCU\SOFTWARE\Microsoft\DirectX\UserGpuPreferences' "backup\backup-$timeStamp.reg"}
write-host "`n"
### paths:
$mcSearchPaths = `
#lunar
"$env:USERPROFILE\.lunarclient\jre", `
#Stock and Forge
"C:\Program Files (x86)\Minecraft Launcher\runtime", `
#Badlion
"C:\ProgramData\BadlionClient", `
#MsStore
"$env:LOCALAPPDATA\Packages\Microsoft.4297127D64EC6_8wekyb3d8bbwe\LocalCache\Local\runtime"
foreach ($item in $mcSearchPaths) {
write-host "-------------------------"
Write-Host "Testing $item" -ForegroundColor Yellow
if (test-path $item) {
write-host "Found: $item" -ForegroundColor Green
$javaWPath = (Get-ChildItem -Path $item -Filter javaw.exe -Recurse).fullname
foreach ($path in $javaWPath) {
write-host "Adding: $path" -ForegroundColor Green
Set-ItemProperty -path HKCU:\SOFTWARE\Microsoft\DirectX\UserGpuPreferences -Name $path -Value "GpuPreference=2;"
}
}
else {
write-host "$item Not Found!" -ForegroundColor Yellow
}
}
write-host "`n"
write-host "Completed successfully. Please remember to restart any minecraft windows that may have been open" -ForegroundColor Green
Pause