-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateSymLinks.ps1
57 lines (49 loc) · 1.64 KB
/
CreateSymLinks.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
#Requires -RunAsAdministrator
[CmdletBinding()]
param (
[Parameter(HelpMessage="Force delete existing destination")]
[Switch]
$Force
)
function New-SymLink {
param (
[string] $Source,
[string] $Destination
)
New-Item -Path $Destination -ItemType SymbolicLink -Value (Get-Item $Source).FullName -Force
}
$symLinks = @(
# powershell links
[System.Tuple]::Create(".\Microsoft.PowerShell_profile.ps1","~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1")
# mpv links
[System.Tuple]::Create(".\mpv\mpv.conf","$env:APPDATA\mpv\mpv.conf")
[System.Tuple]::Create(".\mpv\input.conf","$env:APPDATA\mpv\input.conf")
[System.Tuple]::Create(".\mpv\shaders","$env:APPDATA\mpv\shaders")
# mpv.net links
[System.Tuple]::Create(".\mpv\mpv.conf","$env:APPDATA\mpv.net\mpv.conf")
[System.Tuple]::Create(".\mpv\input.conf","$env:APPDATA\mpv.net\input.conf")
[System.Tuple]::Create(".\mpv\shaders","$env:APPDATA\mpv.net\shaders")
)
Push-Location $PsScriptRoot
foreach ($link in $symLinks) {
$source = $link.Item1
$destination = $link.Item2
if (Test-Path $destination) {
$msg = "Destination exists for: $destination.`nDelete? y/n"
$userInput = ""
if ($Force) {
$userInput = "y"
}
while ($userInput -notmatch "[yn]" ) {
$userInput = Read-Host $msg
}
if ($userInput -eq "y") {
Remove-Item -Recurse $destination
}
else {
Write-Warning "Did not delete existing destination: $destination"
}
}
New-SymLink -Source $link.Item1 -Destination $link.Item2
}
Pop-Location