Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b18245b13d | ||
|
|
317727961e |
+26
-33
@@ -1,55 +1,48 @@
|
||||
Param( [Parameter()] [String[]] $installPath )
|
||||
$adb=$false
|
||||
$fastboot=$false
|
||||
|
||||
if (Get-Command "adb" -ErrorAction SilentlyContinue){
|
||||
$adb=$true
|
||||
}
|
||||
if (Get-Command "fastboot" -ErrorAction SilentlyContinue){
|
||||
$fastboot=$true
|
||||
}
|
||||
Param( [Parameter(Position=0)] [String[]] $installPath )
|
||||
Set-PSDebug -Trace 2
|
||||
$ErrorActionPreference = 'Inquire'
|
||||
$shell = New-Object -ComObject Wscript.Shell
|
||||
$adb=Get-Command "adb" -ErrorAction SilentlyContinue
|
||||
$fastboot=Get-Command "fastboot" -ErrorAction SilentlyContinue
|
||||
|
||||
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 }
|
||||
Invoke-Command -ScriptBlock {
|
||||
$ErrorActionPreference = 'Ignore'
|
||||
adb kill-server
|
||||
}
|
||||
}
|
||||
if($installPath.Length.Equals(0)){
|
||||
Write-Output "platform-tools location not found"
|
||||
$installPath="$HOME\AppData\Roaming\SideQuest\platform-tools\"
|
||||
$installPath="$env:APPDATA\SideQuest\platform-tools"
|
||||
}
|
||||
}
|
||||
Write-Output "installPath=$installPath"
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
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"
|
||||
Set-PSDebug -Off
|
||||
Expand-Archive -Path "$env:temp\platform-tools-latest-windows.zip" -DestinationPath "$env:temp" -Force
|
||||
Set-PSDebug -Trace 2
|
||||
Copy-Item -Path "$env:temp\platform-tools\*" -Destination "$installPath\" -Force
|
||||
|
||||
$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"
|
||||
|
||||
$shell.Popup("Done!")
|
||||
+24
-21
@@ -1,42 +1,45 @@
|
||||
Param( [Parameter()] [String[]] $installPath )
|
||||
$adb=$false
|
||||
$fastboot=$false
|
||||
|
||||
if (Get-Command "adb" -ErrorAction SilentlyContinue){
|
||||
$adb=$true
|
||||
}
|
||||
if (Get-Command "fastboot" -ErrorAction SilentlyContinue){
|
||||
$fastboot=$true
|
||||
}
|
||||
Param( [Parameter(Position=0)] [String[]] $installPath )
|
||||
Set-PSDebug -Trace 2
|
||||
$ErrorActionPreference = 'Inquire'
|
||||
$shell = New-Object -ComObject Wscript.Shell
|
||||
$adb=Get-Command "adb" -ErrorAction SilentlyContinue
|
||||
$fastboot=Get-Command "fastboot" -ErrorAction SilentlyContinue
|
||||
|
||||
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 }
|
||||
Invoke-Command -ScriptBlock {
|
||||
$ErrorActionPreference = 'Ignore'
|
||||
adb kill-server
|
||||
}
|
||||
}
|
||||
if($installPath.Length.Equals(0)){
|
||||
Write-Output "Location not found"
|
||||
$installPath="C:\android-platform-tools"
|
||||
}
|
||||
}
|
||||
Write-Output "installPath=$installPath"
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
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 "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"
|
||||
Set-PSDebug -Off
|
||||
Expand-Archive -Path "$env:temp\platform-tools-latest-windows.zip" -DestinationPath "$env:temp" -Force
|
||||
Set-PSDebug -Trace 2
|
||||
Copy-Item -Path "$env:temp\platform-tools\*" -Destination "$installPath\" -Force
|
||||
|
||||
$shell.Popup("Done!")
|
||||
Reference in New Issue
Block a user