More reliable game searcher
This commit is contained in:
parent
1e4e164a5e
commit
3eb7f022e9
1 changed files with 24 additions and 23 deletions
|
@ -22,20 +22,10 @@ if (-not $steam_dir) {
|
||||||
$steam_dir = Get-RegistryValue "HKLM:\SOFTWARE\WOW6432Node\Valve\Steam" "InstallPath"
|
$steam_dir = Get-RegistryValue "HKLM:\SOFTWARE\WOW6432Node\Valve\Steam" "InstallPath"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Fallback to searching for Steam.exe on C: drive
|
# Fallback to searching for Steam.exe on all drives
|
||||||
if (-not $steam_dir) {
|
|
||||||
Write-Host "No registry key found. Searching for Steam executable on C: drive..."
|
|
||||||
$steam_exe = Get-ChildItem -Path 'C:\' -Recurse -Include "Steam.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
|
|
||||||
|
|
||||||
if ($steam_exe) {
|
|
||||||
$steam_dir = Split-Path $steam_exe.FullName -Parent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Fallback to searching for Steam.exe on drives from D: onwards
|
|
||||||
if (-not $steam_dir) {
|
if (-not $steam_dir) {
|
||||||
Write-Host "No registry key found. Searching for Steam executable on all drives..."
|
Write-Host "No registry key found. Searching for Steam executable on all drives..."
|
||||||
$drives = Get-PSDrive -PSProvider FileSystem | Where-Object { $_.Name -gt 'C' }
|
$drives = Get-PSDrive -PSProvider FileSystem | Where-Object { $_.Name -ge 'C' }
|
||||||
|
|
||||||
foreach ($drive in $drives) {
|
foreach ($drive in $drives) {
|
||||||
$steam_exe = Get-ChildItem -Path "$($drive.Name):\" -Recurse -Include "Steam.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
|
$steam_exe = Get-ChildItem -Path "$($drive.Name):\" -Recurse -Include "Steam.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||||
|
@ -55,26 +45,37 @@ if (-not $steam_dir) {
|
||||||
|
|
||||||
Write-Host "Steam installation path: $steam_dir"
|
Write-Host "Steam installation path: $steam_dir"
|
||||||
|
|
||||||
# Check for Garry's Mod installation
|
# Initialize Garry's Mod directory as null
|
||||||
$gmod_dir = Join-Path $steam_dir "steamapps\common\GarrysMod"
|
$gmod_dir = $null
|
||||||
if (-not (Test-Path (Join-Path $steam_dir "steamapps\appmanifest_4000.acf"))) {
|
|
||||||
|
# Check for Garry's Mod installation in the primary Steam library
|
||||||
|
$gmod_check_path = Join-Path $steam_dir "steamapps\appmanifest_4000.acf"
|
||||||
|
if (Test-Path $gmod_check_path) {
|
||||||
|
$gmod_dir = Join-Path $steam_dir "steamapps\common\GarrysMod"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check for Garry's Mod in additional Steam library folders if not found in the primary
|
||||||
|
if (-not $gmod_dir) {
|
||||||
$library_folders_path = Join-Path $steam_dir "steamapps\libraryfolders.vdf"
|
$library_folders_path = Join-Path $steam_dir "steamapps\libraryfolders.vdf"
|
||||||
|
|
||||||
if (Test-Path $library_folders_path) {
|
if (Test-Path $library_folders_path) {
|
||||||
$lines = Get-Content $library_folders_path
|
$library_folders = (Get-Content $library_folders_path) -join "`n"
|
||||||
foreach ($line in $lines) {
|
$library_paths = $library_folders -split '(?=\s*"\d+"\s*{)' # Split by each library entry
|
||||||
if ($line -match '^\s*"\d+"\s+"(.+)"$') {
|
|
||||||
|
foreach ($library in $library_paths) {
|
||||||
|
if ($library -match '"path"\s*"\s*(.+)\s*"') {
|
||||||
$library_path = $matches[1]
|
$library_path = $matches[1]
|
||||||
if (Test-Path (Join-Path $library_path "steamapps\appmanifest_4000.acf")) {
|
}
|
||||||
$gmod_dir = Join-Path $library_path "steamapps\common\GarrysMod"
|
|
||||||
break
|
if ($library -match '"4000"') {
|
||||||
}
|
$gmod_dir = Join-Path $library_path "steamapps\common\GarrysMod"
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not (Test-Path $gmod_dir)) {
|
if (-not $gmod_dir) {
|
||||||
Write-Host "GMod installation path not found"
|
Write-Host "GMod installation path not found"
|
||||||
Read-Host "Press Enter to exit"
|
Read-Host "Press Enter to exit"
|
||||||
exit
|
exit
|
||||||
|
|
Loading…
Reference in a new issue