1
1
# Script version
2
- $scriptVersion = " v1.5.2 "
2
+ $scriptVersion = " v1.6 "
3
3
Write-Host " weget installer $scriptVersion " - ForegroundColor Cyan
4
4
5
- Write-Host " Sorry installer temporarly disabled!"
6
- exit
7
-
8
5
# Define installation paths
9
6
$userPath = Join-Path $env: APPDATA " KRWCLASSIC\weget"
10
7
$adminPath = Join-Path ${env: ProgramFiles} " KRWCLASSIC\weget"
@@ -42,7 +39,7 @@ if ([string]::IsNullOrEmpty($installPath)) {
42
39
$existingPaths = @ ($userPath , $adminPath ) | Where-Object { Test-Path (Join-Path $_ " weget.exe" ) }
43
40
if ($existingPaths ) {
44
41
Write-Host " weget is already installed at: $ ( $existingPaths -join ' , ' ) " - ForegroundColor Yellow
45
- $installPath = $existingPaths [ 0 ] # Use the first found path
42
+ $installPath = $existingPaths
46
43
} else {
47
44
# Create directory if it does not exist
48
45
if (! (Test-Path $installPath )) {
@@ -56,26 +53,24 @@ $wegetExePath = Join-Path $installPath "weget.exe"
56
53
Write-Host " Expected weget.exe path: $wegetExePath " - ForegroundColor Magenta
57
54
if (Test-Path $wegetExePath ) {
58
55
Write-Host " Verifying existing installation..." - ForegroundColor Cyan
56
+ }
57
+
58
+ # Verify existing installation
59
+ if (Test-Path $wegetExePath ) {
59
60
try {
60
- $version = & $wegetExePath -- version 2>&1
61
- if ($LASTEXITCODE -eq 0 ) {
62
- $existingHash = Get-FileHashValue $wegetExePath
63
- $latestUrl = " https://raw.githubusercontent.com/KRWCLASSIC/weget/refs/heads/main/install/latest_release.txt"
64
- $binaryUrl = Invoke-WebRequest - Uri $latestUrl - UseBasicParsing | Select-Object - ExpandProperty Content
65
- $tempExeDestination = Join-Path $installPath " weget_temp.exe"
66
- Invoke-WebRequest - Uri $binaryUrl - OutFile $tempExeDestination - ErrorAction Stop
67
- $newHash = Get-FileHashValue $tempExeDestination
68
- if ($existingHash -ne $newHash ) {
69
- Write-Host " New version detected. Updating weget..." - ForegroundColor Green
70
- Move-Item - Path $tempExeDestination - Destination $wegetExePath - Force
71
- } else {
72
- Write-Host " Existing installation is up to date." - ForegroundColor Green
73
- Remove-Item $tempExeDestination - Force
74
- exit 0
75
- }
61
+ $existingHash = Get-FileHashValue $wegetExePath
62
+ $latestUrl = " https://raw.githubusercontent.com/KRWCLASSIC/weget/refs/heads/main/install/latest_release.txt"
63
+ $binaryUrl = Invoke-WebRequest - Uri $latestUrl - UseBasicParsing | Select-Object - ExpandProperty Content
64
+ $tempExeDestination = Join-Path $installPath " weget_temp.exe"
65
+ Invoke-WebRequest - Uri $binaryUrl - OutFile $tempExeDestination - ErrorAction Stop
66
+ $newHash = Get-FileHashValue $tempExeDestination
67
+ if ($existingHash -ne $newHash ) {
68
+ Write-Host " New version detected. Updating weget..." - ForegroundColor Green
69
+ Move-Item - Path $tempExeDestination - Destination $wegetExePath - Force
76
70
} else {
77
- Write-Host " Existing installation verification failed" - ForegroundColor Red
78
- exit 1
71
+ Write-Host " Existing installation is up to date." - ForegroundColor Green
72
+ Remove-Item $tempExeDestination - Force
73
+ exit 0
79
74
}
80
75
} catch {
81
76
Write-Host " Failed to verify existing installation: $_ " - ForegroundColor Red
0 commit comments