-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistry.ps1
29 lines (25 loc) · 1.05 KB
/
registry.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
function Get-CurrentUserSteamRegistryKeyPath {
return @("HKCU:\Software\Valve\Steam", "SteamPath")
}
function Get-LocalMachineSteamRegistryKeyPath {
return @("HKLM:\SOFTWARE\WOW6432Node\Valve\Steam", "InstallPath")
}
function Find-SteamDirectory {
$steamRegistryPath = Get-CurrentUserSteamRegistryKeyPath
$path = $steamRegistryPath[0]
$key = $steamRegistryPath[1]
if ((Test-Path -Path "$path") -and ($null -ne (Get-ItemProperty -Path "$path" -Name "$key" -ErrorAction SilentlyContinue)))
{
return Get-ItemProperty -Path "$path" -Name "$key" | Select-Object -ExpandProperty "$key"
} else {
$steamRegistryPath = Get-LocalMachineSteamRegistryKeyPath
$path = $steamRegistryPath[0]
$key = $steamRegistryPath[1]
if ((Test-Path -Path "$path") -and ($null -ne (Get-ItemProperty -Path "$path" -Name "$key" -ErrorAction SilentlyContinue)))
{
return Get-ItemProperty -Path "$path" -Name "$key" | Select-Object -ExpandProperty "$key"
} else {
return $null
}
}
}