-
Notifications
You must be signed in to change notification settings - Fork 13
/
run-ac-recipes.ps1
64 lines (52 loc) · 1.75 KB
/
run-ac-recipes.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
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
#Requires -RunAsAdministrator
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent -Resolve
Write-Output "Running from $scriptDir"
$target = Split-Path -Path "$scriptDir" -Parent
Start-Transcript -Path "$target\run.log"
function label([string]$texter) {
$len = $texter.Length
$filler = "-" * $len
$spacer = " " * $len
Write-Output ""
Write-Output ""
Write-Output "/-$filler-\"
Write-Output "| $spacer |"
Write-Output "| $texter |"
Write-Output "| $spacer |"
Write-Output "\-$filler-/"
Write-Output ""
}
# https://stackoverflow.com/a/50758683
function refresh-path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") +
";" +
[System.Environment]::GetEnvironmentVariable("Path","User")
}
label "Running recipes..."
Get-ChildItem "$pwd\recipes" |
ForEach-Object {
if ($_ -eq ".gitkeep") {
continue
}
$extension = [IO.Path]::GetExtension($_)
if ($extension -eq ".ps1") {
label "$_ PowerShell script"
powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -File "recipes\$_"
} elseif ($extension -eq ".cmd") {
label "$_ Batch script"
Invoke-Expression "recipes\$_"
} elseif ($extension -eq ".reg") {
label "$_ Registry patch"
Invoke-Expression "regedit /s registry\$_"
} else {
label "Skipping $_ - unsupported extension."
}
# Update PATH if necessary
refresh-path
}
Write-Output ""
Write-Output ""
Write-Output "Aperture Control finished."
Write-Output "You might want to restart your computer to finish installation and apply all the settings."
Start-Sleep -Seconds 30
Stop-Transcript