blob: 2180d0dab4c434abba041a78eed383479c2b84bd (
plain)
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
|
# vim: set sts=2 sw=2 et :
function Get-MSYS2 {
# Handle some default paths first. This also works if a user installed a
# system-wide instance of msys64 in these locations, and in that case the
# shortcuts won't be found by the code in the rest of this function.
if (Test-Path "C:\msys64") {
return "C:\msys64"
}
if (Test-Path "D:\msys64") {
return "D:\msys64"
}
$Shortcuts = Get-ChildItem -Recurse "$env:AppData\Microsoft\Windows\Start Menu" -Include *.lnk
$Shell = New-Object -ComObject WScript.Shell
foreach ($Shortcut in $Shortcuts) {
$WD = $Shell.CreateShortcut($Shortcut).WorkingDirectory
if ($WD -clike "*msys64") {
return $WD
}
}
}
function Is-Installed($Name) {
$Shortcuts = Get-ChildItem -Recurse "$env:AppData\Microsoft\Windows\Start Menu" -Include *.lnk
$Shell = New-Object -ComObject WScript.Shell
foreach ($Shortcut in $Shortcuts) {
if ($Shortcut -clike "*\$Name.lnk") {
return $true
}
$WD = $Shell.CreateShortcut($Shortcut).TargetPath
if ($WD -clike "*\$Name.exe") {
return $true
}
}
return $false
}
function Is-Newer ($Name, $Version) {
$ErrorActionPreference = 'SilentlyContinue'
$have = (Get-Command $Name)
$ErrorActionPreference = 'Continue'
if (!$have) {
return $false
}
if ($have.Version -ge $Version) {
return $true
}
$have_version = $have.Version.ToString()
$confirm = Read-Host "$Name version $have_version is too old (need $Version), install a newer version with Choco? [Y/n] "
if ($confirm -eq 'n') {
Write-Host "Please upgrade $Name manually before running Cerbero"
return $true
}
return $false
}
|