-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
111 lines (98 loc) · 5.13 KB
/
Copy pathinstall.ps1
File metadata and controls
111 lines (98 loc) · 5.13 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
# Smart System Manager (ssm) 1-Line Automated Windows Installer Script
$ErrorActionPreference = 'Stop'
Clear-Host
Write-Host " ███████╗███████╗███╗ ███╗ v1.0.0"
Write-Host " ██╔════╝██╔════╝████╗ ████║ High-Performance Windows System Optimizer"
Write-Host " ███████╗███████╗██╔████╔██║ Open-Source Native Rust CLI"
Write-Host " ╚════██║╚════██║██║╚██╔╝██║ https://github.com/thisath111/ssm"
Write-Host " ███████║███████║██║ ╚═╝ ██║"
Write-Host " ╚══════╝╚══════╝╚═╝ ╚═╝`n"
# Check for Administrator Privileges
$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Host "[x] ERROR: Administrator privileges required!" -ForegroundColor Red
Write-Host "Please right-click PowerShell, select 'Run as Administrator', and try again.`n" -ForegroundColor Yellow
return
}
$installDir = "C:\ssm"
$exePath = Join-Path $installDir "ssm.exe"
$downloadUrl = "https://github.com/thisath111/ssm/releases/latest/download/ssm.exe"
$isUpdate = Test-Path -Path $exePath
if ($isUpdate) {
Write-Host ">> Updating Smart System Manager (v1.0.0)...`n" -ForegroundColor Green
} else {
Write-Host ">> Installing Smart System Manager (v1.0.0)...`n" -ForegroundColor Green
}
# 1. Handle existing installation
if ($isUpdate) {
Write-Host " [~] Stopping existing background service..." -ForegroundColor Yellow
& sc.exe stop SmartSystemManager 2>$null | Out-Null
Start-Sleep -Milliseconds 500
}
# 2. Create Directory
if (!(Test-Path -Path $installDir)) {
New-Item -ItemType Directory -Path $installDir -Force | Out-Null
Write-Host " [+] Created directory: $installDir" -ForegroundColor DarkGray
}
# 3. Download Binary
Write-Host " [*] Downloading highly-optimized Windows binary..." -ForegroundColor Cyan
$downloadSuccess = $false
try {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $downloadUrl -OutFile $exePath -UseBasicParsing -ErrorAction Stop
$downloadSuccess = $true
} catch {
Write-Host " [!] Primary download failed: $_" -ForegroundColor Yellow
Write-Host " [*] Falling back to curl..." -ForegroundColor Cyan
if (Get-Command curl.exe -ErrorAction SilentlyContinue) {
& curl.exe -sSL -o "$exePath" "$downloadUrl"
if ($LASTEXITCODE -eq 0) { $downloadSuccess = $true }
}
}
if ($downloadSuccess -and (Test-Path -Path $exePath)) {
Write-Host " [+] Binary downloaded successfully." -ForegroundColor Green
} else {
Write-Host "`n [x] ERROR: Failed to download ssm.exe!" -ForegroundColor Red
Write-Host " Check your internet connection or GitHub availability." -ForegroundColor Yellow
return
}
# 4. PATH Registration
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$installDir*") {
$newPath = "$userPath;$installDir".Trim(';')
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
Write-Host " [+] Registered PATH variable ($installDir)" -ForegroundColor DarkGray
}
if ($env:Path -notlike "*$installDir*") {
$env:Path = "$installDir;$env:Path"
}
# Broadcast environment variable update
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class Win32 {
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam, uint flags, uint timeout, out IntPtr result);
}
"@ -ErrorAction SilentlyContinue
# 5. Native Service Registration
Write-Host " [*] Initializing Windows Native Daemon..." -ForegroundColor Cyan
try {
# We pipe to Out-Null or capture it to prevent the duplicated Rust CLI banner from ruining the neat installer UI
$serviceOutput = & "$exePath" service install 2>&1
Write-Host " [+] Background Service registered & started." -ForegroundColor Green
} catch {
Write-Host " [!] Service installation warning: $_" -ForegroundColor Yellow
}
# 6. Summary
Write-Host "`n==================================================" -ForegroundColor DarkGray
Write-Host " SUCCESS: Smart System Manager is Ready!" -ForegroundColor Green
Write-Host "==================================================" -ForegroundColor DarkGray
Write-Host " Location : $exePath" -ForegroundColor White
Write-Host " Service : SmartSystemManager (Running)" -ForegroundColor White
Write-Host " Autostart: Enabled" -ForegroundColor White
Write-Host "`n Try running these commands now:" -ForegroundColor Cyan
Write-Host " > ssm boost (Max performance mode)" -ForegroundColor Yellow
Write-Host " > ssm clean (Purge standby RAM)" -ForegroundColor Yellow
Write-Host " > ssm stats (Live dashboard)" -ForegroundColor Yellow
Write-Host "==================================================`n" -ForegroundColor DarkGray