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"
|
||||
}
|
||||
|
||||
# Fallback to searching for Steam.exe on C: drive
|
||||
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
|
||||
# Fallback to searching for Steam.exe on all drives
|
||||
if (-not $steam_dir) {
|
||||
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) {
|
||||
$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"
|
||||
|
||||
# Check for Garry's Mod installation
|
||||
$gmod_dir = Join-Path $steam_dir "steamapps\common\GarrysMod"
|
||||
if (-not (Test-Path (Join-Path $steam_dir "steamapps\appmanifest_4000.acf"))) {
|
||||
# Initialize Garry's Mod directory as null
|
||||
$gmod_dir = $null
|
||||
|
||||
# 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"
|
||||
|
||||
if (Test-Path $library_folders_path) {
|
||||
$lines = Get-Content $library_folders_path
|
||||
foreach ($line in $lines) {
|
||||
if ($line -match '^\s*"\d+"\s+"(.+)"$') {
|
||||
$library_folders = (Get-Content $library_folders_path) -join "`n"
|
||||
$library_paths = $library_folders -split '(?=\s*"\d+"\s*{)' # Split by each library entry
|
||||
|
||||
foreach ($library in $library_paths) {
|
||||
if ($library -match '"path"\s*"\s*(.+)\s*"') {
|
||||
$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"
|
||||
Read-Host "Press Enter to exit"
|
||||
exit
|
||||
|
|
Loading…
Reference in a new issue