-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwindows.ps1
More file actions
96 lines (77 loc) · 4.16 KB
/
windows.ps1
File metadata and controls
96 lines (77 loc) · 4.16 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
#!/usr/bin/env pwsh
# Enable TLSv1.2 for compatibility with older clients for current session
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# https://github.com/farag2/ADB-Debloating/blob/acc9a11a2688e0bb851c30a524b1f76f851f14eb/src/Download_ADB.ps1#L5-L10
if ($Host.Version.Major -eq 5) {
# Progress bar can significantly impact cmdlet performance
# https://github.com/PowerShell/PowerShell/issues/2138
$Script:ProgressPreference = "SilentlyContinue"
}
# Solution for colored output in PowerShell:
# https://stackoverflow.com/a/78753310/21165921
#
# Color table:
# https://stackoverflow.com/a/28938235/21165921
# The Android™ logo is taken from: https://gist.github.com/okineadev/0cde43c0a2161212d28a6efd67fec442
# Android is a trademark of Google LLC.
Write-Host @"
$([char]27)[0;32m
+++++ +++++
+++++++ +++++++
+++++++ +++++++
++++++++ +++++++
++++++++ ++++++++++++++++ ++++++++
++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++
+++++++++++$([char]27)[0;30m**$([char]27)[0;32m+++++++++++++++++++++++$([char]27)[0;30m*$([char]27)[0;32m+++++++++++
++++++++++$([char]27)[0;30m%%%%#$([char]27)[0;32m++++++++++++++++++++$([char]27)[0;30m*%%%%$([char]27)[0;32m++++++++++
++++++++++$([char]27)[0;30m#%%%%#$([char]27)[0;32m++++++++++++++++++++$([char]27)[0;30m#%%%%#$([char]27)[0;32m++++++++++
++++++++++++$([char]27)[0;30m#%%*$([char]27)[0;32m++++++++++++++++++++++$([char]27)[0;30m*%%%$([char]27)[0;32m++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$([char]27)[0m
"@
Write-Host
Write-Host " platform-tools installer"
Write-Host " (C) Okinea Dev (2024-present)" -ForegroundColor DarkGray
Write-Host
Write-Host "This script will install platform-tools in `"C:\platform-tools`" and add it to PATH."
Write-Host
Write-Host -ForegroundColor Cyan "Please read the terms and conditions here: $([char]27)[4mhttps://developer.android.com/studio/terms$([char]27)[24m"
$agreement = Read-Host -Prompt "Do you agree with the terms? $([char]27)[1m(Y/n)$([char]27)[0m"
if ($agreement -notmatch '^(?i)y$') {
Write-Host "❌ You must agree with the terms and conditions to proceed."
Write-Host
exit
}
Add-Type -AssemblyName System.IO.Compression.FileSystem
$downloadUrl = "https://dl.google.com/android/repository/platform-tools-latest-windows.zip"
$destinationPath = "$env:TEMP\platform-tools-latest-windows.zip"
$extractPath = "C:\platform-tools"
Write-Host "📥 Downloading platform-tools..."
Invoke-WebRequest -Uri $downloadUrl -OutFile $destinationPath -Verbose
Write-Host "📦 Extracting platform-tools..."
$tempUnzipPath = Join-Path $env:TEMP "platform-tools-temp"
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $tempUnzipPath
Expand-Archive -Path $destinationPath -DestinationPath $tempUnzipPath -Force
$sourceFolder = Get-ChildItem -Path $tempUnzipPath -Directory | Where-Object { $_.Name -eq "platform-tools" }
if ($sourceFolder) {
Copy-Item -Path $sourceFolder.FullName -Destination $extractPath -Recurse -Force
Write-Host "✅ platform-tools extracted to $extractPath"
} else {
Write-Host "❌ platform-tools folder not found in the archive!"
}
$envPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($envPath -notlike "*$extractPath*") {
Write-Host "Adding C:\platform-tools to system $([char]27)[1mPATH$([char]27)[0m..."
$newPath = "$envPath;$extractPath"
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
} else {
Write-Host "ℹ️ C:\platform-tools is already in system $([char]27)[1mPATH$([char]27)[0m."
}
Remove-Item -Path $destinationPath -Force
Write-Host "✅ Installation complete. Please restart your computer to apply changes."