forked from flarialmc/newcdn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.ps1
69 lines (56 loc) · 2.47 KB
/
install.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
65
66
67
68
69
# Define global variables
$location = "$env:APPDATA\Flarial"
$url = "https://backup.flarial.net/launcher/latest.zip"
$silent = $false
# Function to create shortcuts
function Create-Shortcut {
param(
[string]$Name,
[string]$Directory,
[string]$TargetFile,
[string]$IconLocation,
[string]$Description
)
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$Directory\$Name.lnk")
$Shortcut.TargetPath = $TargetFile
$Shortcut.IconLocation = $IconLocation
$Shortcut.Description = $Description
$Shortcut.Save()
}
# Function for installation
function Install {
Start-Sleep -Seconds 2
if (Test-Path $location) {
Remove-Item -Path $location -Recurse -Force
}
try {
if (-not (Test-Path $location)) {
New-Item -ItemType Directory -Path $location | Out-Null
}
$webClient = New-Object System.Net.WebClient
$webClient.DownloadFile($url, "$location\latest.zip")
# Perform actions after download completion
Expand-Archive -Path "$location\latest.zip" -DestinationPath $location -Force
Remove-Item "$location\latest.zip"
Create-Shortcut -Name "Flarial" -Directory ([Environment]::GetFolderPath("Desktop")) -TargetFile "$location\Flarial.Launcher.exe" -IconLocation "$location\Flarial.Launcher.exe" -Description "Launch Flarial"
Create-Shortcut -Name "Flarial" -Directory ([Environment]::GetFolderPath("StartMenu")) -TargetFile "$location\Flarial.Launcher.exe" -IconLocation "$location\Flarial.Launcher.exe" -Description "Launch Flarial"
Create-Shortcut -Name "Flarial Minimal" -Directory ([Environment]::GetFolderPath("Desktop")) -TargetFile "$location\Flarial.Minimal.exe" -IconLocation "$location\Flarial.Minimal.exe" -Description "Launch Flarial Minimal"
Create-Shortcut -Name "Flarial Minimal" -Directory ([Environment]::GetFolderPath("StartMenu")) -TargetFile "$location\Flarial.Minimal.exe" -IconLocation "$location\Flarial.Minimal.exe" -Description "Launch Flarial Minimal"
if (-not $silent) {
Write-Host "Flarial has been installed. You can find it on your desktop and in the Windows menu."
}
}
catch {
Write-Error "An error occurred: $_"
# Display error message
}
}
# Main script
if ($args.Length -gt 0) {
# Custom installation path logic (if needed)
}
if (Test-Path $location) {
Get-ChildItem $location | Remove-Item -Force
}
Install