7 Commits
3 changed files with 71 additions and 89 deletions
+2 -2
View File
@@ -5,9 +5,9 @@ This is a re-implementation of the [15 seconds ADB Installer](https://forum.xda-
This installer requires an internet connection.
The main component is [the PowerShell script](https://github.com/josephsmendoza/ADB-Installer/blob/master/install.ps1) which downloads [the latest android platform tools for windows](https://dl.google.com/android/repository/platform-tools-latest-windows.zip) and installs them to either `C:\adb`, an auto-detected previous install location, or a path you can specify via `-installPath`.
The main component is [the PowerShell script](https://github.com/josephsmendoza/ADB-Installer/blob/master/install.ps1) which downloads [the latest android platform tools for windows](https://dl.google.com/android/repository/platform-tools-latest-windows.zip) and installs them to either `C:\android-platform-tools`, an auto-detected previous install location, or a path you can specify via `-installPath`.
For conveinence, this is wrapped in an `.exe` file which runs the script with `ExecutionPolicy` set to `Bypass`. This file is fully automated.
For convenience, this is wrapped in an `.exe` file which runs the script with `ExecutionPolicy` set to `Bypass`. This file is fully automated.
Icon is from [Google via icon-icons.com](https://icon-icons.com/icon/adb/90476)
-55
View File
@@ -1,55 +0,0 @@
Param( [Parameter()] [String[]] $installPath )
$adb=$false
$fastboot=$false
if (Get-Command "adb" -ErrorAction SilentlyContinue){
$adb=$true
}
if (Get-Command "fastboot" -ErrorAction SilentlyContinue){
$fastboot=$true
}
if($installPath.Length.Equals(0)){
if(!$adb -and $fastboot){
Write-Output "fastboot installed without adb"
Write-Output "Checking fastboot location via --version ..."
$installPath=fastboot --version | Select-String -Pattern "(?<=installed as )(.+)(?=\\.*\.exe)" | % { $_.Matches } | % { $_.Value }
}
if($adb){
Write-Output "adb installed, checking location via --version ..."
$installPath=adb --version | Select-String -Pattern "(?<=installed as )(.+)(?=\\.*\.exe)" | % { $_.Matches } | % { $_.Value }
}
if($installPath.Length.Equals(0)){
Write-Output "platform-tools location not found"
$installPath="$HOME\AppData\Roaming\SideQuest\platform-tools\"
}
}
Write-Output "installPath=$installPath"
if(!$adb -and !$fastboot){
Write-Output "Adding $installPath to `$PATH ..."
$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
$newpath = "$oldpath;$installPath"
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath
}
Write-Output "Checking Windows Defender Status..."
$defender=cmd /c sc query Windefend
if ( "$defender" -like "*RUNNING*" ){
Write-Output "Defender is running, adding exclusions for adb..."
Add-MpPreference -ExclusionPath $installPath
Add-MpPreference -ExclusionProcess "adb.exe"
} else {
Write-Output "Defender is not running, skipping exclusions"
}
Write-Output "Downloading platform-tools-latest-windows.zip to $env:temp ..."
Import-Module BitsTransfer
Start-BitsTransfer -Source "https://dl.google.com/android/repository/platform-tools-latest-windows.zip" -Destination "$env:temp\platform-tools-latest-windows.zip"
Write-Output "Extracting $env:temp\platform-tools-latest-windows.zip to $installPath ..."
Expand-Archive -Path "$env:temp\platform-tools-latest-windows.zip" -DestinationPath "$installPath" -Force
Write-Output "Installing Quest ADB Driver"
$PSScriptRootLegacy=split-path -parent $MyInvocation.MyCommand.Definition
Start-Process $PSScriptRootLegacy/android_winusb.inf -Verb Install
Write-Output "Done!"
Read-Host -Prompt "Press Enter to continue"
+69 -32
View File
@@ -1,42 +1,79 @@
Param( [Parameter()] [String[]] $installPath )
$adb=$false
$fastboot=$false
Param( [Parameter(Position=0)] [String[]] $installPath )
Set-PSDebug -Trace 2
$ErrorActionPreference = 'Inquire'
$adbUrl = "https://dl.google.com/android/repository/platform-tools-latest-windows.zip"
$adbZip = "$env:temp\platform-tools-latest-windows.zip"
$adbProcess = Get-Process -Name adb -ErrorAction SilentlyContinue
$shell = New-Object -ComObject Wscript.Shell
$fastboot = Get-Command "fastboot" -ErrorAction SilentlyContinue
if (Get-Command "adb" -ErrorAction SilentlyContinue){
$adb=$true
}
if (Get-Command "fastboot" -ErrorAction SilentlyContinue){
$fastboot=$true
$adbDownloadJob = Start-Job -ScriptBlock {
$ErrorActionPreference = 'Inquire'
Write-Verbose "Start-BitsTransfer -Source $using:adbURL -Destination $using:adbZip" -Verbose
Start-BitsTransfer -Source $using:adbURL -Destination $using:adbZip
}
if($installPath.Length.Equals(0)){
if(!$adb -and $fastboot){
Write-Output "fastboot installed without adb"
Write-Output "Checking fastboot location via --version ..."
$installPath=fastboot --version | Select-String -Pattern "(?<=installed as )(.+)(?=\\.*\.exe)" | % { $_.Matches } | % { $_.Value }
$adbSearchJob = Start-Job -ScriptBlock {
$ErrorActionPreference = 'Inquire'
Get-ChildItem -Path $env:SystemDrive\ -Include "adb.exe","fastboot.exe" -Exclude $env:SystemRoot\*,(Split-Path -Path $HOME)\* -ErrorAction SilentlyContinue -Recurse | ForEach-Object {Split-Path -Path $_.FullName} | Select-Object -Unique
}
$adbUserSearchJob = Start-Job -ScriptBlock {
$ErrorActionPreference = 'Inquire'
Get-ChildItem -Path $HOME\ -Include "adb.exe","fastboot.exe" -Exclude $env:temp\* -ErrorAction SilentlyContinue -Recurse -Force | ForEach-Object {Split-Path -Path $_.FullName} | Select-Object -Unique
}
if($adbProcess){
$adb=$adbProcess.Path
$adbProcess.Kill()
} else {
$adb=Get-Command "adb" -ErrorAction SilentlyContinue
}
if(!$installPath){
if(!$adb -and $fastboot){
$installPath=&$fastboot --version | Select-String -Pattern "(?<=installed as )(.+)(?=\\.*\.exe)" | % { $_.Matches } | % { $_.Value }
}
if($adb){
$installPath=&$adb --version | Select-String -Pattern "(?<=installed as )(.+)(?=\\.*\.exe)" | % { $_.Matches } | % { $_.Value }
}
if(!$installPath){
$installPath="C:\android-platform-tools"
if($shell.Popup("automatic adb locating failed, Would you like to search for a previously downloaded adb? This process can take a long time, depending on how fast your storage device is",
0,'ADB Installer',36) -eq 6){
$result=@($installPath)
$result+=Receive-Job -Job $adbUserSearchJob -Wait -AutoRemoveJob
$result+=Receive-Job -Job $adbSearchJob -Wait -AutoRemoveJob
$installPath=($result | Out-GridView -OutputMode Single)
} else {
Remove-Job $adbSearchJob -Force
Remove-Job $adbUserSearchJob -Force
}
}
}
if($adb){
Write-Output "adb installed, checking location via --version ..."
$installPath=adb --version | Select-String -Pattern "(?<=installed as )(.+)(?=\\.*\.exe)" | % { $_.Matches } | % { $_.Value }
}
if($installPath.Length.Equals(0)){
Write-Output "Location not found"
$installPath="C:\android-platform-tools"
}
}
Write-Output "installPath=$installPath"
if(!$adb -and !$fastboot){
Write-Output "Adding $installPath to `$PATH ..."
$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
if( !$oldpath.Contains($installPath) ){
$newpath = "$oldpath;$installPath"
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath
}
Write-Output "Downloading platform-tools-latest-windows.zip to $env:temp ..."
Import-Module BitsTransfer
Start-BitsTransfer -Source "https://dl.google.com/android/repository/platform-tools-latest-windows.zip" -Destination "$env:temp\platform-tools-latest-windows.zip"
Write-Output "Extracting $env:temp\platform-tools-latest-windows.zip to $installPath ..."
Expand-Archive -Path "$env:temp\platform-tools-latest-windows.zip" -DestinationPath "$installPath" -Force
Write-Output "Done!"
Read-Host -Prompt "Press Enter to continue"
if ( (cmd /c sc query Windefend) -like "*RUNNING*" ){
Add-MpPreference -ExclusionPath $installPath
Add-MpPreference -ExclusionProcess "adb.exe"
} else {
$shell.Popup("Windows Defender is not running! If you have antivirus, exclude $installPath")
}
Receive-Job -Job $adbDownloadJob -Wait -AutoRemoveJob
Start-Job -ScriptBlock {
$ErrorActionPreference = 'Inquire'
Write-Verbose "Expand-Archive -Path $using:adbZip -DestinationPath $env:temp -Force" -Verbose
Expand-Archive -Path $using:adbZip -DestinationPath $env:temp -Force
Remove-Item $using:adbZip -Verbose
} | Receive-Job -Wait -AutoRemoveJob
if(!(Test-Path $installPath)){mkdir $installPath}
Copy-Item -Path "$env:temp\platform-tools\*" -Destination "$installPath\" -Force
Remove-Item -Path "$env:temp\platform-tools" -Recurse -Force
$shell.Popup("Done!")