Repository navigation
Expand file tree
/
Copy pathInstall-Experimental.ps1
More file actions
162 lines (135 loc) · 5.43 KB
/
Copy pathInstall-Experimental.ps1
File metadata and controls
162 lines (135 loc) · 5.43 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Install-Experimental.ps1
# Nine Lives Audio v1.1 Experimental Installer
# Self-extracting portable installer for Windows 10/11 (x64)
param(
[string]$InstallDir = "$env:LOCALAPPDATA\NineLivesAudio",
[switch]$NoDesktopShortcut,
[switch]$NoStartMenu,
[switch]$Uninstall
)
$ErrorActionPreference = "Stop"
$AppName = "Nine Lives Audio"
$ExeName = "NineLivesAudio.exe"
$Version = "1.1.0-Experimental"
function Write-Header {
Write-Host ""
Write-Host "============================================" -ForegroundColor Cyan
Write-Host " $AppName v$Version" -ForegroundColor Cyan
Write-Host " Experimental Build Installer" -ForegroundColor DarkCyan
Write-Host "============================================" -ForegroundColor Cyan
Write-Host ""
}
function Remove-Installation {
Write-Host "Uninstalling $AppName..." -ForegroundColor Yellow
# Stop running instances
Get-Process -Name "NineLivesAudio" -ErrorAction SilentlyContinue | Stop-Process -Force
Start-Sleep -Seconds 1
# Remove shortcuts
$desktopLink = "$env:USERPROFILE\Desktop\$AppName.lnk"
$startMenuDir = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\$AppName"
if (Test-Path $desktopLink) { Remove-Item $desktopLink -Force }
if (Test-Path $startMenuDir) { Remove-Item $startMenuDir -Recurse -Force }
# Remove app directory (but not user data)
if (Test-Path $InstallDir) {
Remove-Item $InstallDir -Recurse -Force
Write-Host "Removed: $InstallDir" -ForegroundColor Green
}
Write-Host ""
Write-Host "Uninstall complete." -ForegroundColor Green
Write-Host "User data preserved at: $env:LOCALAPPDATA\NineLivesAudio" -ForegroundColor DarkGray
Write-Host "(Delete that folder manually to remove all data)" -ForegroundColor DarkGray
return
}
function New-Shortcut {
param([string]$Path, [string]$Target, [string]$Icon)
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut($Path)
$shortcut.TargetPath = $Target
if ($Icon) { $shortcut.IconLocation = $Icon }
$shortcut.Save()
}
# ── Main ──
Write-Header
if ($Uninstall) {
Remove-Installation
exit 0
}
# Check for running instances
$running = Get-Process -Name "NineLivesAudio" -ErrorAction SilentlyContinue
if ($running) {
Write-Host "Nine Lives Audio is currently running." -ForegroundColor Yellow
$choice = Read-Host "Close it and continue? (Y/n)"
if ($choice -eq "n" -or $choice -eq "N") {
Write-Host "Installation cancelled." -ForegroundColor Red
exit 1
}
$running | Stop-Process -Force
Start-Sleep -Seconds 2
}
Write-Host "Install directory: $InstallDir" -ForegroundColor White
Write-Host ""
# Locate source files (same directory as this script)
$sourceDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$sourceApp = Join-Path $sourceDir $ExeName
if (-not (Test-Path $sourceApp)) {
# Try looking in a subfolder named 'app'
$sourceDir = Join-Path $sourceDir "app"
$sourceApp = Join-Path $sourceDir $ExeName
}
if (-not (Test-Path $sourceApp)) {
Write-Host "ERROR: Cannot find $ExeName in the extracted folder." -ForegroundColor Red
Write-Host "Make sure you extracted the entire ZIP before running this script." -ForegroundColor Yellow
exit 1
}
# Create install directory
if (-not (Test-Path $InstallDir)) {
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
}
# Copy files
Write-Host "Copying files..." -ForegroundColor Cyan
$fileCount = (Get-ChildItem -Path $sourceDir -Recurse -File).Count
$copied = 0
Get-ChildItem -Path $sourceDir -Recurse -File | ForEach-Object {
$relativePath = $_.FullName.Substring($sourceDir.Length + 1)
$destPath = Join-Path $InstallDir $relativePath
$destDir = Split-Path -Parent $destPath
if (-not (Test-Path $destDir)) {
New-Item -ItemType Directory -Path $destDir -Force | Out-Null
}
Copy-Item $_.FullName $destPath -Force
$copied++
if ($copied % 50 -eq 0) {
Write-Progress -Activity "Installing $AppName" -Status "$copied / $fileCount files" -PercentComplete (($copied / $fileCount) * 100)
}
}
Write-Progress -Activity "Installing $AppName" -Completed
Write-Host " Copied $fileCount files." -ForegroundColor Green
# Desktop shortcut
if (-not $NoDesktopShortcut) {
$desktopLink = "$env:USERPROFILE\Desktop\$AppName.lnk"
$exePath = Join-Path $InstallDir $ExeName
New-Shortcut -Path $desktopLink -Target $exePath -Icon $exePath
Write-Host " Desktop shortcut created." -ForegroundColor Green
}
# Start Menu
if (-not $NoStartMenu) {
$startMenuDir = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\$AppName"
if (-not (Test-Path $startMenuDir)) {
New-Item -ItemType Directory -Path $startMenuDir -Force | Out-Null
}
$exePath = Join-Path $InstallDir $ExeName
New-Shortcut -Path "$startMenuDir\$AppName.lnk" -Target $exePath -Icon $exePath
Write-Host " Start Menu entry created." -ForegroundColor Green
}
Write-Host ""
Write-Host "============================================" -ForegroundColor Green
Write-Host " Installation complete!" -ForegroundColor Green
Write-Host "============================================" -ForegroundColor Green
Write-Host ""
Write-Host " Location: $InstallDir" -ForegroundColor White
Write-Host " Version: $Version" -ForegroundColor White
Write-Host ""
$launch = Read-Host "Launch $AppName now? (Y/n)"
if ($launch -ne "n" -and $launch -ne "N") {
Start-Process (Join-Path $InstallDir $ExeName)
}