├── Run.bat ├── OC ├── Assests │ ├── file.png │ ├── folder.png │ ├── uparrow.png │ └── checkbox.png ├── Invoke-SharedFunctions.ps1 ├── SharedScripts │ ├── Show-CustomDialog.ps1 │ ├── OCVariables.ps1 │ └── Get-ADBDevice.ps1 ├── Update-Tools.ps1 └── Get-AndroidInstalledAppsInfo.ps1 ├── KK ├── Terminal │ ├── Execute Batch or Cmd File Interactively.ps1 │ ├── Execute PowerShell Script File In Interactive Shell Windows Terminal.ps1 │ └── Open Any Shell In Terminal Here.ps1 ├── File-Folder │ ├── Move Folder Contents To Opposite Pane.ps1 │ ├── Merge Entire Directories From Both Panes Into Single Folder.ps1 │ └── Rename Selected File With ClipBoard History Item.ps1 ├── PowerShell │ ├── Output Env Vars From OC.ps1 │ ├── Add CurrentDir To PS Default Variables.ps1 │ └── List And Optionally Remove Custom PS Variables.ps1 ├── Env Variables │ └── Add Current Directory To User Path Environment Variable.ps1 └── AndroidADB │ ├── Launch-Phone-Gui.ps1 │ └── Launch-Phone-Gui-New.ps1 ├── LICENSE ├── Install-PreReqs.ps1 ├── README.md └── Install.ps1 /Run.bat: -------------------------------------------------------------------------------- 1 | powershell.exe -NoExit -NoProfile -File "%~dp0Install-PreReqs.ps1" -------------------------------------------------------------------------------- /OC/Assests/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kamekairos/KK-OneCommanderScripts/HEAD/OC/Assests/file.png -------------------------------------------------------------------------------- /OC/Assests/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kamekairos/KK-OneCommanderScripts/HEAD/OC/Assests/folder.png -------------------------------------------------------------------------------- /OC/Assests/uparrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kamekairos/KK-OneCommanderScripts/HEAD/OC/Assests/uparrow.png -------------------------------------------------------------------------------- /OC/Assests/checkbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kamekairos/KK-OneCommanderScripts/HEAD/OC/Assests/checkbox.png -------------------------------------------------------------------------------- /KK/Terminal/Execute Batch or Cmd File Interactively.ps1: -------------------------------------------------------------------------------- 1 | #PS7 2 | $SelectedFiles = $Env:Selected_Files -split "`r`n" 3 | $SelectedFiles | ForEach-Object {cmd /K $_} 4 | -------------------------------------------------------------------------------- /KK/File-Folder/Move Folder Contents To Opposite Pane.ps1: -------------------------------------------------------------------------------- 1 | #PS7 2 | $SelectedFolder = $Env:CURRENT_DIR 3 | $opDir = $Env:Current_Dir_Inactive 4 | Move-Item -Path "$SelectedFolder\*" -Destination $opDir -------------------------------------------------------------------------------- /KK/PowerShell/Output Env Vars From OC.ps1: -------------------------------------------------------------------------------- 1 | #PS7 2 | $Env:Current_Dir 3 | $Env:Current_Dir_Inactive 4 | $Env:Selected_Items 5 | $Env:Selected_Items_Inactive 6 | $Env:OC_SETTINGS_DIR 7 | $Env:OC_SCRIPTS_DIR -------------------------------------------------------------------------------- /KK/Terminal/Execute PowerShell Script File In Interactive Shell Windows Terminal.ps1: -------------------------------------------------------------------------------- 1 | #PS7 2 | $SelectedFiles = $Env:Selected_Files -split "`r`n" 3 | $SelectedFiles | ForEach-Object {pwsh.exe -NoExit -File $_} 4 | -------------------------------------------------------------------------------- /OC/Invoke-SharedFunctions.ps1: -------------------------------------------------------------------------------- 1 | #Global Function Scripts To Call 2 | . "$PSScriptroot\SharedScripts\OCVariables.ps1" 3 | . "$PSScriptroot\SharedScripts\Get-ADBDevice.ps1" 4 | . "$PSScriptroot\SharedScripts\Show-CustomDialog.ps1" -------------------------------------------------------------------------------- /KK/PowerShell/Add CurrentDir To PS Default Variables.ps1: -------------------------------------------------------------------------------- 1 | #PS7 2 | $CurDir = $env:CURRENT_DIR 3 | $VarName = Read-Host -Prompt "Please Enter The Name of the Variable To represent the path: $CurDir" 4 | $CustomAddedVars = Import-Clixml "$env:OC_SCRIPTS_DIR\..\KK\Export\CusPSVars.xml" 5 | $CustomAddedVars.Add($VarName,$CurDir) 6 | 7 | $CustomAddedVars | Export-Clixml -Path "$env:OC_SCRIPTS_DIR\..\KK\Export\CusPSVars.xml" -Force -------------------------------------------------------------------------------- /KK/PowerShell/List And Optionally Remove Custom PS Variables.ps1: -------------------------------------------------------------------------------- 1 | #PS7 2 | 3 | $CustomAddedVars = Import-Clixml "$env:OC_SCRIPTS_DIR\..\KK\Export\CusPSVars.xml" 4 | 5 | $SelectedVars = $CustomAddedVars | Out-GridView -Title "Select Vars To Remove!" -OutputMode Multiple 6 | 7 | foreach ($VarKey in $SelectedVars.Key) { 8 | $CustomAddedVars.Remove("$VarKey") 9 | } 10 | $CustomAddedVars | Export-Clixml "$env:OC_SCRIPTS_DIR\..\KK\Export\CusPSVars.xml" -Force -------------------------------------------------------------------------------- /OC/SharedScripts/Show-CustomDialog.ps1: -------------------------------------------------------------------------------- 1 | function Show-CustomDialog { 2 | param ( 3 | [Parameter(Position=0)] 4 | [string] 5 | $Title, 6 | 7 | [Parameter(Position=1)] 8 | [string] 9 | $PromptText, 10 | 11 | [Parameter(Position=2)] 12 | [string] 13 | $ButtonsType = "YesNoCancel", 14 | 15 | [Parameter(Position=3)] 16 | [string] 17 | $IconType = "Question" 18 | ) 19 | Add-Type -AssemblyName System.Windows.Forms 20 | $MBResults = [System.Windows.Forms.MessageBox]::Show($PromptText, $Title, [System.Windows.Forms.MessageBoxButtons]::$ButtonsType, [System.Windows.Forms.MessageBoxIcon]::$IconType) 21 | 22 | return $MBResults 23 | 24 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 KPC Integrations 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /OC/SharedScripts/OCVariables.ps1: -------------------------------------------------------------------------------- 1 | function Set-OCVars { 2 | param( 3 | [Parameter(Mandatory = $false, 4 | HelpMessage = 'OC Current Directory Variable/Path ($CurrentDir)')] 5 | [string] 6 | $CurrentDir, 7 | [Parameter(Mandatory = $false, 8 | HelpMessage = 'OC Current Selected Files ($SelMultiple)')] 9 | [string] 10 | $SelMultiple, 11 | [Parameter(Mandatory = $false, 12 | HelpMessage = 'OC Opposite Directory Variable/Path ($OpDir)')] 13 | [string] 14 | $OpDir, 15 | [Parameter(Mandatory = $false, 16 | HelpMessage = 'OC Opposite Selected Files ($OpSelMultiple)')] 17 | [string] 18 | $OpSelMultiple 19 | ) 20 | $SelMultList = ($SelMultiple -split "\r?\n") 21 | $OpSelMultList = ($OpSelMultiple -split "\r?\n") 22 | 23 | $OCVarHash = @{ 24 | CurrentDir = $CurrentDir 25 | SelectedFiles = $SelMultList 26 | OpDir = $OpDir 27 | OpSelectedFiles = $OpSelMultList 28 | } 29 | $OCVarHash | Export-Clixml -Path "$PSScriptRoot\..\Export\Vars.xml" -Force 30 | 31 | } 32 | 33 | function Get-OCVars { 34 | $GetOCVars = Import-Clixml -Path "$PSScriptRoot\..\Export\Vars.xml" 35 | return $GetOCVars 36 | } -------------------------------------------------------------------------------- /KK/Env Variables/Add Current Directory To User Path Environment Variable.ps1: -------------------------------------------------------------------------------- 1 | #PS7 2 | $Choices = [System.Management.Automation.Host.ChoiceDescription[]] @("&Top", "&Bottom" ) 3 | $TopBot = $host.UI.PromptForChoice('Add Directory to the Top of the PATH ENV Var, or Bottom to Add Directory To End of PATH env Var', '', $Choices, 1) 4 | $CurDir = $env:CURRENT_DIR 5 | $newPath = $CurDir 6 | 7 | $envPath = 'HKCU:\Environment' 8 | $key = Get-Item -Path $envPath 9 | $existingPath = $key.GetValue('PATH', '', 'DoNotExpandEnvironmentNames') 10 | $key.Dispose() 11 | 12 | if($TopBot -eq 1) { 13 | $newParams = @{ 14 | Path = $envPath 15 | Name = 'PATH' 16 | Value = "$existingPath$([System.IO.Path]::PathSeparator)$newPath" 17 | PropertyType = 'ExpandString' 18 | Force = $true 19 | } 20 | } 21 | elseif ($TopBot -eq 0) { 22 | $newParams = @{ 23 | Path = $envPath 24 | Name = 'PATH' 25 | Value = "$newPath$([System.IO.Path]::PathSeparator)$existingPath" 26 | PropertyType = 'ExpandString' 27 | Force = $true 28 | } 29 | } 30 | else { 31 | Write-Host "You can do it, pick Top or Bottom!" 32 | } 33 | New-ItemProperty @newParams | Out-Null -------------------------------------------------------------------------------- /OC/Update-Tools.ps1: -------------------------------------------------------------------------------- 1 | $platformToolsUpdateUrl = "https://dl.google.com/android/repository/platform-tools-latest-windows.zip" 2 | Invoke-WebRequest -Uri $platformToolsUpdateUrl -OutFile "$env:TEMP\platform-tools.zip" 3 | Expand-Archive -Path "$env:TEMP\platform-tools.zip" -DestinationPath "$env:TEMP" -Force 4 | Get-ChildItem -Path "$env:TEMP\platform-tools\*adb*" | Copy-Item -Destination "$PSScriptRoot\Tools\" -Force 5 | 6 | $NETSDKRefUpdateUrl = "https://www.nuget.org/api/v2/package/Microsoft.Windows.SDK.NET.Ref" 7 | Invoke-WebRequest -Uri $NETSDKRefUpdateUrl -OutFile "$env:TEMP\Microsoft.Windows.SDK.NET.Ref.zip" 8 | Expand-Archive -Path "$env:TEMP\Microsoft.Windows.SDK.NET.Ref.zip" -DestinationPath "$env:TEMP\Microsoft.Windows.SDK.NET.Ref\" -Force 9 | Get-ChildItem -Path "$env:TEMP\Microsoft.Windows.SDK.NET.Ref\lib\net8.0\Microsoft.Windows.SDK.NET.dll" | Copy-Item -Destination "$PSScriptRoot\Tools\" -Force 10 | Get-ChildItem -Path "$env:TEMP\Microsoft.Windows.SDK.NET.Ref\lib\net8.0\WinRT.Runtime.dll" | Copy-Item -Destination "$PSScriptRoot\Tools\" -Force 11 | 12 | $AAPT2TarUrl = "https://android.googlesource.com/platform/prebuilts/sdk/+archive/refs/heads/main/tools/windows/bin.tar.gz" 13 | Invoke-WebRequest -Uri $AAPT2TarUrl -OutFile "$env:TEMP\prebuilttools.tar.gz" 14 | $SRB4 = $PSScriptRoot 15 | Set-Location $env:TEMP 16 | tar -xf "$env:TEMP\prebuilttools.tar.gz" 17 | Copy-Item -Path "$env:TEMP\aapt2.exe" -Destination "$SRB4\Tools\aapt2.exe" -Force -------------------------------------------------------------------------------- /KK/File-Folder/Merge Entire Directories From Both Panes Into Single Folder.ps1: -------------------------------------------------------------------------------- 1 | #PS7 2 | Add-Type -AssemblyName System.Windows.Forms 3 | Add-Type -AssemblyName System.Drawing 4 | 5 | $CurDir = $env:CURRENT_DIR 6 | $OpDir = $Env:Current_Dir_Inactive 7 | 8 | $FolderPathDialog = New-Object System.Windows.Forms.FolderBrowserDialog 9 | $FolderPathDialog.Description = "Choose A Destination Path To Merge Both Panes Into" 10 | $FolderPathDialog.RootFolder = "MyComputer" 11 | $FolderPathDialog.SelectedPath = "$env:SystemDrive" 12 | 13 | if ($FolderPathDialog.ShowDialog() -eq "OK") { 14 | Copy-Item -Path "$CurDir\*" -Destination $FolderPathDialog.SelectedPath -Recurse -Force 15 | Copy-Item -Path "$OpDir\*" -Destination $FolderPathDialog.SelectedPath -Recurse -Force 16 | } 17 | elseif ($FolderPathDialog.ShowDialog() -eq "CANCEL") { 18 | $ButtonType = [System.Windows.Forms.MessageBoxButtons]::Ok 19 | 20 | $MessageIcon = [System.Windows.Forms.MessageBoxIcon]::Information 21 | 22 | $MessageBody = "You have canceled the Folder Picking Dialog. Ending Script." 23 | 24 | $MessageTitle = "Dialog Closed" 25 | 26 | [System.Windows.Forms.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon) 27 | } 28 | else { 29 | $ButtonType2 = [System.Windows.Forms.MessageBoxButtons]::Ok 30 | 31 | $MessageIcon2 = [System.Windows.Forms.MessageBoxIcon]::Warning 32 | 33 | $MessageBody2 = "An Unknown Error Occured. Ending Script." 34 | 35 | $MessageTitle2 = "Unknown Error" 36 | 37 | [System.Windows.Forms.MessageBox]::Show($MessageBody2,$MessageTitle2,$ButtonType2,$MessageIcon2) 38 | } 39 | 40 | -------------------------------------------------------------------------------- /Install-PreReqs.ps1: -------------------------------------------------------------------------------- 1 | Add-Type -AssemblyName System.Windows.Forms 2 | if (!(Get-Command wt.exe -CommandType Application -ErrorAction SilentlyContinue)) { 3 | $MBResults = & "$PSScriptRoot\OC\SharedScripts\Show-CustomDialog.ps1" -Title "Install Terminal?" -PromptText "Windows Terminal is NOT installed. Install Now?" -ButtonsType "YesNo" -IconType "Question" 4 | if ($MBResults -eq [System.Windows.Forms.DialogResult]::Yes) { 5 | winget install Microsoft.WindowsTerminal 6 | } 7 | else { 8 | Write-Host "Not Installing Windows Terminal..." 9 | } 10 | } 11 | else { 12 | Write-Host "WT Already Installed" 13 | } 14 | 15 | if (!(Get-Command -Name pwsh -CommandType Application -ErrorAction SilentlyContinue)) { 16 | Write-Host "Are we In?" $env:Path 17 | $MBResults2 = & "$PSScriptRoot\OC\SharedScripts\Show-CustomDialog.ps1" -Title "Install PS7+ ?" -PromptText "PS7+ is required for this script pack but it not installed...please select ok to install or cancell to quit installation of this script pack!" -ButtonsType "OkCancel" -IconType "Exclamation" 18 | if ($MBResults2 -eq [System.Windows.Forms.DialogResult]::OK) { 19 | winget install Microsoft.PowerShell 20 | } 21 | else { 22 | $env:Path 23 | Write-Host "Aborting Installation!" 24 | exit 25 | } 26 | } 27 | else { 28 | Write-Host "PowerShell 7 Already Installed" 29 | } 30 | $scriptroot = $PSScriptRoot 31 | powershell.exe -NoExit -NoProfile -Command { 32 | param ( 33 | [string] 34 | $ScriptRootPar 35 | ) 36 | powershell.exe -NoExit -File "$ScriptRootPar\Install.ps1"} -Args $scriptroot -------------------------------------------------------------------------------- /KK/Terminal/Open Any Shell In Terminal Here.ps1: -------------------------------------------------------------------------------- 1 | #PS7 2 | try { 3 | $wtContentJson = Get-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -ErrorAction Stop 4 | } 5 | catch { 6 | $wtContentJson = Get-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\LocalState\settings.json" 7 | } 8 | $CurDir = $env:CURRENT_DIR 9 | $wtContentObj = $wtContentJson | ConvertFrom-Json 10 | $promptGuids = $wtContentObj.profiles.list.guid 11 | $promptNames = $wtContentObj.profiles.list.name 12 | 13 | Add-Type -AssemblyName System.Windows.Forms 14 | Add-Type -AssemblyName System.Drawing 15 | 16 | $mainForm = New-Object System.Windows.Forms.Form 17 | $mainForm.Size = New-Object System.Drawing.Size(500,850) 18 | $mainForm.StartPosition = "CenterScreen" 19 | 20 | $listBox = New-Object System.Windows.Forms.ListBox 21 | $listBox.Size = New-Object System.Drawing.Size(425,650) 22 | $listBox.Location = New-Object System.Drawing.Size(25,25) 23 | foreach ($promptName in $promptNames) { 24 | $listBox.Items.Add($promptName) | Out-Null 25 | } 26 | 27 | $okButton = New-Object System.Windows.Forms.Button 28 | $okButton.Text = "Launch Prompt" 29 | $okButton.Size = New-Object System.Drawing.Size(100,50) 30 | $okButton.Dock = "Bottom" 31 | 32 | $mainForm.Controls.Add($listBox) 33 | $mainForm.Controls.Add($okButton) 34 | 35 | $Script:LaunchTerminalCmd = { 36 | $CurGuid = $promptGuids[$listBox.SelectedIndex] 37 | wt -p $CurGuid -d $CurDir 38 | $mainForm.Close() | Out-Null 39 | } 40 | 41 | $okButton.Add_Click($Script:LaunchTerminalCmd) 42 | 43 | 44 | $mainForm.ShowDialog() | Out-Null -------------------------------------------------------------------------------- /OC/SharedScripts/Get-ADBDevice.ps1: -------------------------------------------------------------------------------- 1 | #Usings and Types For Forms 2 | using namespace System.Windows.Forms 3 | using namespace System.Drawing 4 | 5 | Add-Type -AssemblyName System.Windows.Forms 6 | Add-Type -AssemblyName System.Drawing 7 | 8 | #Code to return Serial Number of selected Device! 9 | #----------------------------------------------- 10 | function Get-ADBDevice { 11 | #Calculations 12 | $ADBDevices = . adb devices 13 | $ADBDevicesParse = $ADBDevices | Select-Object -Skip 1 -SkipLast 1 14 | 15 | #Main Form Box 16 | $PhoneSelForm = [Form]::new() 17 | 18 | $PhoneSelForm.AutoSize = $true 19 | $PhoneSelForm.StartPosition = [FormStartPosition]::CenterScreen 20 | $PhoneSelForm.BackColor = [Color]::FromArgb(40, 44, 52) 21 | $PhoneSelForm.ForeColor = [Color]::White 22 | $PhoneSelForm.Padding = 25 23 | $PhoneSelForm.Text = "Select An ADB Device!" 24 | 25 | #Label For Phone Serials 26 | $Label = New-Object System.Windows.Forms.Label 27 | $Label.Text = "Select One Device's Serial Number, or Network Address:Port and Select Okay" 28 | $Label.Dock = "Top" 29 | $Label.Height = 50 30 | 31 | #ListBox For ADB Results 32 | $Listbox = [ListBox]::new() 33 | $Listbox.BackColor = [Color]::FromArgb(32, 34, 39) 34 | $Listbox.ForeColor = [Color]::White 35 | foreach ($Device in $ADBDevicesParse){ 36 | $DeviceParse = $Device -split "device" 37 | $DeviceParseParse = $DeviceParse[0].Trim() 38 | $Listbox.Items.Add($DeviceParseParse) | Out-Null 39 | } 40 | $Listbox.Dock = "Top" 41 | $Listbox.SelectionMode = "One" 42 | 43 | $OkButtonSB = { 44 | $PhoneSelForm.Close() | Out-Null 45 | 46 | } 47 | 48 | #OkButton 49 | $OkButton = New-Object Button 50 | $OkButton.Text = "Ok" 51 | $OkButton.BackColor = [Color]::FromArgb(32, 34, 39) 52 | $OkButton.ForeColor = [Color]::White 53 | $OkButton.Add_Click($OkButtonSB) 54 | $OkButton.Dock = "Bottom" 55 | $PhoneSelForm.AcceptButton = $OkButton 56 | 57 | #Adding up Controls 58 | $PhoneSelForm.Controls.Add($Listbox) 59 | $PhoneSelForm.Controls.Add($Label) 60 | $PhoneSelForm.Controls.Add($OkButton) 61 | $PhoneSelForm.ShowDialog() | Out-Null 62 | 63 | #Returning SN from function... 64 | return $Listbox.SelectedItem 65 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KPC-OneCommanderScripts 2 | A collection of scripts for the alternative file manager OneCommander. Offers various features such as executing powershell scripts or batach files in an interactive prompt so that errors and messages can be seen, rather than the default of a hidden or auto closing Windows Powershell instance. Open current dir in any installed shell that is selected via a gui. Android functionality like pulling or pushing files via adb 3 | # Installation Instructions 4 | 1. Clone the repository to any location 5 | 2. Make Sure OneCommander is running. 6 | 3. Run the Install.ps1 for a first time Installation and wait for the script to finish. This will create a KPC folder in the Scripts Folder with the Initial Scripts you will see in OC's script menu. It will also create a folder name KPC in the Resources OC folder with additional scripts that are invoked by the OC script menu scripts. This is due to limitations with how scripting is implemented in OC. I updated the Install.ps1 script to check to see if this repo is already installed, so when updating just run Install.ps1 again. 7 | 4. That's it, I'll be implementing gui's for most complex tasks but easy task will be done using the currently selected files and current/opposite dirs open. 8 | # Features 9 | ## ADB Scripts: 10 | ### Phone GUI 11 | 1. Makeshift File Browser & Features - I made a gui to browse main storage on android and select one or multiple files. You can then transfer the selected phone files to the current directory, the opposite pane directory, or a custom folder through a folder picking dialog. 12 | 2. Install And Apk - With this tool you can install apks from your computer directly to your phone with adb's aideloading capabilities 13 | 3. Get Apk And Common Names - As far as I know this tool is the only one for windows that will get the common names of apps OneCommander next to the packagename like com.onecommander.com. You can then select as many packages and hit okay and the following can be done. Uninstall selected programs, clear cached for selected programs, clear data for selected program 14 | ## Environment Variable Scripts: 15 | ### Add Current Path To User Environment Path Variable - This one is useful for when you use a lot of portable packages to add custom paths to the PATH USER Environment. Add the active pane's path to the USER PATH environment variable. 16 | ## PowerShell Scripts: 17 | ### Add Custom PowerShell Var Containing Current OC Directory - Add's a custom variable that's loaded via the powershell profile at each start letting you save the current path to a customly named var that be accessed with a $ infront of what you named the variable. "cd $NamedVar" for example. 18 | ### List and Remove Custom Powershell Vars - A way to organize and remove customly set var's from this script pack. Might have to restart shell for it to reset the variables. 19 | ##Terminal Scripts: 20 | ### Execute .bat or .cmd file interactively - This will attempt to open the selected batch or cmd file in windows terminal under the command prompt profile 21 | ### Execute .ps1 interactively - Let's you select a .ps1 file and run this script to start it in an interactive pwsh prompt. 22 | ### Open All Terminals Here - Get's a list of installed shells from Windows Terminal and then lets you select and launch that shell in the current directory in the active pane. 23 | # Support 24 | - If you have questions or would like to contribute to this script pack email me at admin@kpcintegrations.com and I will respond as soon as I have time. 25 | - Any bugs can be reported on the OC google group, or added as an issue to this repo! 26 | -------------------------------------------------------------------------------- /KK/File-Folder/Rename Selected File With ClipBoard History Item.ps1: -------------------------------------------------------------------------------- 1 | #PS7 2 | Add-Type -Path "$PSScriptRoot\..\..\..\KK\Tools\Microsoft.Windows.SDK.NET.dll" 3 | Add-Type -AssemblyName System.Windows.Forms 4 | Add-Type -AssemblyName System.Drawing 5 | 6 | $SelectedFile = ($env:Selected_Files) 7 | 8 | $asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | Where-Object { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0] 9 | function Await($WinRtTask, $ResultType) { 10 | $asTask = $asTaskGeneric.MakeGenericMethod($ResultType) 11 | $netTask = $asTask.Invoke($null, @($WinRtTask)) 12 | $netTask.Wait(-1) | Out-Null 13 | $netTask.Result 14 | } 15 | $op = [Windows.ApplicationModel.DataTransfer.Clipboard]::GetHistoryItemsAsync() 16 | $result = Await ($op) ([Windows.ApplicationModel.DataTransfer.ClipboardHistoryItemsResult]) 17 | 18 | $op2 = $result.Items.Content.GetTextAsync() 19 | $listy = @() 20 | foreach($o in $op2) { 21 | 22 | $listycandidate = Await ($o) ([string]) 23 | if ($null -ne $listycandidate) { 24 | $listy += $listycandidate 25 | } 26 | } 27 | 28 | 29 | $mainform = New-Object System.Windows.Forms.Form 30 | $mainform.AutoScaleMode = "Dpi" 31 | $mainform.AutoSize = $true 32 | $mainform.AutoSizeMode = [System.Windows.Forms.AutoSizeMode]::GrowOnly 33 | $mainform.Text = "Rename With Clipboard History" 34 | $mainform.StartPosition = "CenterScreen" 35 | $mainform.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::Fixed3D 36 | $mainform.BackColor = [System.Drawing.Color]::FromArgb(24, 24, 24) 37 | $mainform.ForeColor = [System.Drawing.Color]::FromArgb(255, 255, 255) 38 | $mainform.ControlBox = $true 39 | $mainform.TopMost = $true 40 | $mainform.Font = [System.Drawing.Font]::new("Consolas",14) 41 | $padding1 = $mainform.Padding 42 | $padding1.All = 15 43 | $mainform.Padding = $padding1 44 | 45 | $flowlayoutpanel1 = New-Object System.Windows.Forms.FlowLayoutPanel 46 | $flowlayoutpanel1.FlowDirection = [System.Windows.Forms.FlowDirection]::TopDown 47 | $flowlayoutpanel1.WrapContents = $false 48 | $flowlayoutpanel1.Dock = "Fill" 49 | $flowlayoutpanel1.AutoSize = $true 50 | 51 | 52 | $label = New-Object System.Windows.Forms.Label 53 | $label.Text = "Please Select A Clipboard Item And Hit Rename" 54 | $label.Dock = "Top" 55 | $label.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter 56 | $label.AutoSize = $true 57 | $label.ForeColor = [System.Drawing.Color]::FromArgb(0, 178, 255) 58 | 59 | $listbox = New-Object System.Windows.Forms.ListBox 60 | foreach($item in $listy) { 61 | $listbox.Items.Add($item) 62 | } 63 | $listbox.Height = (($listbox.ItemHeight + 5) * $listbox.Items.Count) + 100 64 | $listbox.HorizontalScrollbar = $true 65 | $listbox.BackColor = [System.Drawing.Color]::FromArgb(57, 57, 57) 66 | $listbox.ForeColor = "White" 67 | $listbox.BorderStyle = [System.Windows.Forms.BorderStyle]::None 68 | $padding2 = $listbox.Padding 69 | $padding2.All = 15 70 | $listbox.Padding = $padding2 71 | 72 | $button1 = New-Object System.Windows.Forms.Button 73 | $button1.Text = "Rename" 74 | $button1.AutoSize = $true 75 | $button1.Dock = "Bottom" 76 | 77 | $flowlayoutpanel1.Controls.Add($label) 78 | $flowlayoutpanel1.Controls.Add($listbox) 79 | $flowlayoutpanel1.Controls.Add($button1) 80 | 81 | 82 | 83 | $mainform.Controls.Add($flowlayoutpanel1) 84 | <#> 85 | $mainform.Add_Resize({ 86 | $listbox.Size = [System.Drawing.Size]::new(($mainform.ClientSize.Width - 2 * $mainform.Padding.Left),($mainform.ClientSize.Height - 2 * $mainform.Padding.Top + $button1.Height + 15)) 87 | }) 88 | #> 89 | 90 | $button1.Add_Click({ 91 | $SelectedClipItem = $listbox.SelectedItem.ToString() 92 | Rename-Item -Path $SelectedFile -NewName $SelectedClipItem 93 | $mainform.Close() 94 | }) 95 | 96 | 97 | 98 | $mainform.ShowDialog() -------------------------------------------------------------------------------- /Install.ps1: -------------------------------------------------------------------------------- 1 | # Installs OC Scripts and PS Scripts that accompany the OC Scripts 2 | # Must Have OneCommander Running While Installing 3 | 4 | $DetectedScriptsFolder = "" 5 | $OCEXEDirPath = (Get-Item -Path (Get-Process OneCommander).Path).Directory.FullName 6 | if ($OCEXEDirPath.Contains("WindowsApp")) { 7 | $DetectedScriptsFolder = "$Env:USERPROFILE\OneCommander\Resources\Scripts\" 8 | } 9 | elseif ($OCEXEDirPath.Contains("Program Files")) { 10 | $DetectedScriptsFolder = "$Env:LOCALAPPDATA\OneCommander\Resources\Scripts\" 11 | } 12 | else { 13 | $DetectedScriptsFolder = "$OCEXEDirPath\Resources\Scripts\" 14 | } 15 | $KKResourcePath = "$DetectedScriptsFolder\..\KK\" 16 | taskkill.exe /IM "adb.exe" /F 17 | New-Item -Path $DetectedScriptsFolder -ItemType Directory -Force 18 | New-Item -Path $KKResourcePath -ItemType Directory -Force 19 | Copy-Item -Recurse -Path "$PSScriptRoot\KK\" -Destination $DetectedScriptsFolder -Force 20 | Copy-Item -Recurse -Path "$PSScriptRoot\OC\*" -Destination $KKResourcePath -Force 21 | $Path = Join-Path $DetectedScriptsFolder "..\KK\Export\" 22 | New-Item -Path $Path -ItemType Directory -Force 23 | $OCSettingsPath = "$OCEXEDirPath\Settings\" 24 | $OCProfilePath = "$OCSettingsPath\OneCommanderProfile.ps1" 25 | if (!(Test-Path $OCProfilePath)) { 26 | New-Item -Path $OCProfilePath -ItemType File -Value "#This is the begining of the OneCommanderProfile.ps1" -Force 27 | } 28 | else { 29 | $OCProfilePathContents = Get-Content -Path $OCProfilePath -Raw 30 | } 31 | $RawProfileContent = @' 32 | #KK-Integrations Script Pack For OneCommander Profile Code...don't remove this unless you want to reinstall after breaking the scripts(some). 33 | if (Test-Path -Path "$PathCusPSVars.xml") { 34 | $CustomVariables = Import-Clixml -Path "$PathCusPSVars.xml" 35 | $CustomVariables.GetEnumerator() | ForEach-Object -Process { New-Variable -Name $_.Name -Value $_.Value -Option AllScope -Scope Global -Force } 36 | } 37 | if ($null -eq $CustomVariables) { 38 | $example = @{} 39 | $example.Add("ExampleVarPath","C:\Windows\System32\drivers\etc\") 40 | $example | Export-Clixml -Path "$Path\CusPSVars.xml" -Force 41 | } 42 | . "$PSSCriptRoot\..\Resources\KK\Invoke-SharedFunctions.ps1" 43 | '@ 44 | $RawProfileParsed = $RawProfileContent.Replace('$Path',$Path) 45 | 46 | if ($OCProfilePathContents -notcontains $RawProfileParsed) { 47 | Add-Content -Path $OCProfilePath -Value "" 48 | Add-Content -Path $OCProfilePath -Value $RawProfileParsed 49 | } 50 | 51 | $OCProfileContent = @' 52 | . "$DetectedScriptsFolder\..\..\Settings\OneCommanderProfile.ps1" 53 | '@ 54 | $OCProfileContentParsed = $OCProfileContent.Replace('$DetectedScriptsFolder',$DetectedScriptsFolder) 55 | if ($PROFILE -notcontains $OCProfileContent) { 56 | Add-Content -Path $PROFILE -Value $OCProfileContentParsed 57 | $PS7PROFILE = $PROFILE.Replace("WindowsPowerShell","PowerShell") 58 | Add-Content -Path $PS7PROFILE -Value $OCProfileContentParsed 59 | } 60 | 61 | 62 | $AlteredScriptExecutorsJson = @' 63 | [ 64 | { 65 | "Executable": "powershell.exe", 66 | "HeaderTags": "#PS", 67 | "Extensions": "ps1", 68 | "Arguments": "-NoExit -File \"SCRIPT_PATH\"" 69 | }, 70 | { 71 | "Executable": "pwsh.exe", 72 | "HeaderTags": "#PS7,#PWSH", 73 | "Extensions": "ps1", 74 | "Arguments": "-NoExit -File \"SCRIPT_PATH\"" 75 | }, 76 | { 77 | "Executable": "wt.exe", 78 | "HeaderTags": "#WT", 79 | "Extensions": "ps1", 80 | "Arguments": "powershell -NoExit -File \"SCRIPT_PATH\"" 81 | }, 82 | { 83 | "Executable": "python.exe", 84 | "HeaderTags": "#PY,#PYTHON", 85 | "Extensions": "py", 86 | "Arguments": "\"SCRIPT_PATH\"" 87 | }, 88 | { 89 | "Executable": "cmd.exe", 90 | "HeaderTags": "#CMD", 91 | "Extensions": "bat", 92 | "Arguments": "/K \"SCRIPT_PATH\"" 93 | } 94 | ] 95 | '@ 96 | $FinSEJson = $AlteredScriptExecutorsJson.Replace('$OCProfilePath',$OCProfilePath) 97 | Set-Content "$OCSettingsPath\ScriptExecutors.json" -Value $FinSEJson -Force 98 | 99 | #. "$KKResourcePath\Update-Tools.ps1" -------------------------------------------------------------------------------- /OC/Get-AndroidInstalledAppsInfo.ps1: -------------------------------------------------------------------------------- 1 | using namespace System.Windows.Forms 2 | using namespace System.Drawing 3 | Add-Type -AssemblyName System.Windows.Forms 4 | Add-Type -AssemblyName System.Drawing 5 | 6 | $mainForm = New-Object Form 7 | $mainForm.AutoSize = $true 8 | $mainForm.StartPosition = "CenterScreen" 9 | $mainForm.Text = "Get Package And Common Name Of Installed Apks" 10 | 11 | $label = New-Object System.Windows.Forms.Label 12 | $label.AutoSize = $true 13 | $label.Location = New-Object System.Drawing.Size(100, 25) 14 | $label.Text = "Select which packages to list" 15 | 16 | $checkbox1 = New-Object System.Windows.Forms.CheckBox 17 | $checkbox1.AutoSize = $true 18 | $checkbox1.Location = New-Object System.Drawing.Size(100, 50) 19 | $checkbox1.Text = "Third Party Packages" 20 | 21 | $checkbox2 = New-Object System.Windows.Forms.CheckBox 22 | $checkbox2.AutoSize = $true 23 | $checkbox2.Location = New-Object System.Drawing.Size(300, 50) 24 | $checkbox2.Text = "System Packages" 25 | 26 | $progressLabel1 = New-Object System.Windows.Forms.Label 27 | $progressLabel1.AutoSize = $true 28 | $progressLabel1.Location = New-Object System.Drawing.Size(100, 100) 29 | $progressLabel1.Text = "Apk Pulling Progress" 30 | 31 | $progressBar = New-Object System.Windows.Forms.ProgressBar 32 | $progressBar.AutoSize = $true 33 | $progressBar.Location = New-Object System.Drawing.Size(100, 150) 34 | $progressBar.Visible = $true 35 | $progressBar.Minimum = 1 36 | $progressBar.Value = 1 37 | 38 | $progressLabel2 = New-Object System.Windows.Forms.Label 39 | $progressLabel2.AutoSize = $true 40 | $progressLabel2.Location = New-Object System.Drawing.Size(300, 100) 41 | $progressLabel2.Text = "Apk Processing Progress" 42 | 43 | $progressBar2 = New-Object System.Windows.Forms.ProgressBar 44 | $progressBar2.AutoSize = $true 45 | $progressBar2.Location = New-Object System.Drawing.Size(300, 150) 46 | $progressBar2.Visible = $true 47 | $progressBar2.Minimum = 1 48 | $progressBar2.Value = 1 49 | 50 | $button = New-Object System.Windows.Forms.Button 51 | $button.AutoSize = $true 52 | $button.Location = New-Object System.Drawing.Size(100, 200) 53 | $button.Text = "OK" 54 | 55 | $listBoxLabel = New-Object System.Windows.Forms.Label 56 | $listBoxLabel.AutoSize = $true 57 | $listBoxLabel.Location = New-Object System.Drawing.Size(100, 250) 58 | $listBoxLabel.Text = "Select Apps From Results:" 59 | 60 | $resultsListBox = New-Object System.Windows.Forms.ListBox 61 | $resultsListBox.AutoSize = $true 62 | $resultsListBox.Location = New-Object System.Drawing.Size(100, 300) 63 | $resultsListBox.SelectionMode = "None" 64 | 65 | $rsultsListCheckBoxLabel = New-Object System.Windows.Forms.Label 66 | $rsultsListCheckBoxLabel.AutoSize = $true 67 | $rsultsListCheckBoxLabel.Location = New-Object System.Drawing.Size(100, 800) 68 | $rsultsListCheckBoxLabel.Text = "Select Action(s) To Take" 69 | 70 | $resultsCheckBox1 = New-Object System.Windows.Forms.CheckBox 71 | $resultsCheckBox1.AutoSize = $true 72 | $resultsCheckBox1.Location = New-Object System.Drawing.Size(100, 800) 73 | $resultsCheckBox1.Text = "Uninstall" 74 | 75 | $resultsCheckBox2 = New-Object System.Windows.Forms.CheckBox 76 | $resultsCheckBox2.AutoSize = $true 77 | $resultsCheckBox2.Location = New-Object System.Drawing.Size(200, 800) 78 | $resultsCheckBox2.Text = "Save Apks To Selected Location" 79 | 80 | $resultsCheckBox3 = New-Object System.Windows.Forms.CheckBox 81 | $resultsCheckBox3.AutoSize = $true 82 | $resultsCheckBox3.Location = New-Object System.Drawing.Size(500, 800) 83 | $resultsCheckBox3.Text = "Clear Cache" 84 | 85 | $resultsCheckBox4 = New-Object System.Windows.Forms.CheckBox 86 | $resultsCheckBox4.AutoSize = $true 87 | $resultsCheckBox4.Location = New-Object System.Drawing.Size(700, 800) 88 | $resultsCheckBox4.Text = "Clear Data" 89 | 90 | $resultsButton = New-Object System.Windows.Forms.Button 91 | $resultsButton.AutoSize = $true 92 | $resultsButton.Location = New-Object System.Drawing.Size(100, 850) 93 | $resultsButton.Text = "Clear Data" 94 | 95 | $buttonSB = { 96 | $Script:Args1 = @() 97 | if ($checkbox1.Checked -and $checkbox2.Checked) { 98 | $Script:Args1 = "-d", "shell", "pm", "list", "packages", "-a", "-f" 99 | } 100 | if ($checkbox1.Checked -and !($checkbox2.Checked)) { 101 | $Script:Args1 = "-d", "shell", "pm", "list", "packages", "-3", "-f" 102 | } 103 | if (!($checkbox1.Checked) -and $checkbox2.Checked) { 104 | $Script:Args1 = "-d", "shell", "pm", "list", "packages", "-s", "-f" 105 | } 106 | $NewLineSplitPackages = & "$PSScriptRoot\Tools\adb.exe" @Args1 107 | $ParsedADBPaths = @() 108 | $ParsedADBPackageNames = @() 109 | foreach ($line in $NewLineSplitPackages) { 110 | $ParsedPath1 = ($line -replace '^package:' -replace '(?<=base\.apk).*') 111 | $PackageName = ($line -split "=")[-1].ToString() 112 | $ParsedADBPaths += $ParsedPath1 113 | $ParsedADBPackageNames += $PackageName 114 | } 115 | $progressBar.Maximum = $ParsedADBPaths.Count 116 | if (Test-Path "$PSScriptRoot\Export\ApkFiles\") { 117 | Remove-Item -Path "$PSScriptRoot\Export\ApkFiles\" -Recurse -Force 118 | } 119 | New-Item -Path "$PSScriptRoot\Export\ApkFiles\" -ItemType Directory -Force 120 | for ($i = 0; $i -lt $ParsedADBPaths.Count; $i++) { 121 | $Args2 = "pull", "$($ParsedADBPaths[$i])", "$PSScriptRoot\Export\ApkFiles\$($ParsedADBPackageNames[$i]).apk" 122 | & "$PSScriptRoot\Tools\adb.exe" @Args2 123 | $progressBar.Increment(1) 124 | } 125 | $GetApks = Get-ChildItem -Path "$PSScriptRoot\Export\ApkFiles\" -File -Force 126 | $CommonNames = @{} 127 | $progressBar2.Maximum = $GetApks.Count 128 | foreach ($apk in $GetApks) { 129 | $Args3 = "dump", "badging", "$($apk.FullName)" 130 | $RawAAPT2Dump = & "$PSScriptRoot\Tools\aapt2.exe" @Args3 131 | $ParsedDump = $RawAAPT2Dump | Select-String "(?<=application-label:')[^']+" | ForEach-Object { $_.Matches.Value } 132 | $CommonNames.Add($apk.BaseName, $ParsedDump) 133 | $progressBar2.Increment(1) 134 | } 135 | $SortedApksByCommonName = $CommonNames.GetEnumerator() | Sort-Object -Property Value 136 | $Script:Results = $SortedApksByCommonName | Out-GridView -Title "Apks & Names" -OutputMode Multiple 137 | 138 | 139 | foreach ($result in $Script:Results) { 140 | $resultsListBox.Items.Add($result.Value) 141 | } 142 | } 143 | $resultButtonSB = { 144 | $SelectFolder = New-Object System.Windows.Forms.FolderBrowserDialog 145 | foreach ($result in $Script:Results) { 146 | if ($resultsCheckBox1.Checked) { 147 | $uninstallArgs = "uninstall", "$($result.Key)" 148 | & "$PSScriptRoot\Tools\adb.exe" @uninstallArgs 149 | } 150 | if ($resultsCheckBox2.Checked) { 151 | if ($SelectFolder.ShowDialog() -eq "OK") { 152 | $selectedFolder = $SelectFolder.SelectedPath 153 | Copy-Item -Path (Get-ChildItem -Path "$PSScriptRoot\Export\ApkFiles\$($result.Key).apk").FullName -Destination $selectedFolder 154 | } 155 | } 156 | if ($resultsCheckBox3.Checked) { 157 | $cacheArgs = '-d', 'shell', 'pm', 'clear', '--cache-only', "$($result.Key)" 158 | & "$PSScriptRoot\Tools\adb.exe" @cacheArgs 159 | } 160 | if ($resultsCheckBox4) { 161 | $cacheArgs = '-d', 'shell', 'pm', 'clear', "$($result.Key)" 162 | & "$PSScriptRoot\Tools\adb.exe" @cacheArgs 163 | } 164 | } 165 | $mainForm.Close() 166 | } 167 | 168 | $button.Add_Click($buttonSB) 169 | $resultsButton.Add_Click($resultButtonSB) 170 | 171 | $mainForm.Controls.Add($label) 172 | $mainForm.Controls.Add($checkbox1) 173 | $mainForm.Controls.Add($checkbox2) 174 | $mainForm.Controls.Add($progressLabel1) 175 | $mainForm.Controls.Add($progressLabel2) 176 | $mainForm.Controls.Add($progressBar) 177 | $mainForm.Controls.Add($progressBar2) 178 | $mainForm.Controls.Add($button) 179 | $mainForm.Controls.Add($listBoxLabel) 180 | $mainForm.Controls.Add($resultsListBox) 181 | $mainForm.Controls.Add($resultsCheckBox1) 182 | $mainForm.Controls.Add($resultsCheckBox2) 183 | $mainForm.Controls.Add($resultsCheckBox3) 184 | $mainForm.Controls.Add($resultsCheckBox4) 185 | $mainForm.Controls.Add($resultsButton) 186 | 187 | 188 | $mainForm.ShowDialog() 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /KK/AndroidADB/Launch-Phone-Gui.ps1: -------------------------------------------------------------------------------- 1 | #PS7 2 | using namespace System.Windows.Forms 3 | using namespace System.Drawing 4 | 5 | Add-Type -AssemblyName System.Windows.Forms 6 | Add-Type -AssemblyName System.Drawing 7 | 8 | $OCVars = Get-OCVars 9 | $CurDir = $OCVars.CurrentDir 10 | $OpDir = $OCVars.OpDir 11 | $SelectedItems = $OCVars.SelectedFiles -split "\n" 12 | 13 | $SelectedADBSerial = Get-ADBDevice 14 | 15 | adb kill-server 16 | 17 | $Global:CurFolPath = "/sdcard/" 18 | $adbInitFolders = & "$PSScriptRoot\Tools\adb.exe" "-s" $SelectedADBSerial "shell" "ls" "$($Global:CurFolPath)" 19 | 20 | $form = [Form]::new() 21 | $form.Size = [Size]::new(1000,900) 22 | $form.BackColor = [Color]::White 23 | $form.StartPosition = [FormStartPosition]::CenterScreen 24 | $form.Font = $DefaultFont.Font 25 | 26 | $page1MenuButton1Image = [Image]::FromFile("$PSScriptRoot\Assests\uparrow.png") 27 | 28 | $page1MenuButton1 = [Button]::new() 29 | $page1MenuButton1.Size = [Size]::new(50,50) 30 | $page1MenuButton1.Image = $page1MenuButton1Image 31 | 32 | $page1Panel = [Panel]::new() 33 | $page1Panel.Dock = [DockStyle]::Fill 34 | 35 | $page2Panel = [Panel]::new() 36 | $page2Panel.Dock = [DockStyle]::Fill 37 | 38 | $page3Panel = [Panel]::new() 39 | $page3Panel.Dock = [DockStyle]::Fill 40 | 41 | $page1MenuPanel = [Panel]::new() 42 | $page1MenuPanel.Dock = "Top" 43 | $page1MenuPanel.Height = 50 44 | $page1MenuPanel.BackColor = [Color]::Black 45 | $page1MenuPanel.Padding = [Padding]::new(0) 46 | $page1MenuPanel.Margin = [Padding]::new(0) 47 | $page1MenuPanel.Controls.Add($page1MenuButton1) 48 | 49 | 50 | $lvImageList = [ImageList]::new() 51 | $lvImageList.Images.Add([Image]::FromFile("$PSScriptRoot\Assests\folder.png")) 52 | $lvImageList.Images.Add([Image]::FromFile("$PSScriptRoot\Assests\file.png")) 53 | $lvImageList.ImageSize = [Size]::new(50,50) 54 | 55 | $listView = [ListView]::new() 56 | $listView.BorderStyle = [BorderStyle]::None 57 | $listView.Dock = [DockStyle]::Fill 58 | $listView.View = [View]::LargeIcon 59 | $listView.BackColor = [Color]::Black 60 | $listView.ForeColor = [Color]::White 61 | $listView.LargeImageList = $lvImageList 62 | foreach ($Item in $adbInitFolders) { 63 | $listView.Items.Add($Item,0) 64 | } 65 | 66 | $listView.Add_DoubleClick({ 67 | Write-Host "In The DoubleClick" 68 | Write-Host "$($listView.SelectedItems[0].Text)" 69 | $Folder = $listView.SelectedItems[0].Text 70 | $Global:CurFolPath = $Global:CurFolPath + $Folder + "/" 71 | $Items = adb -s $SelectedADBSerial shell ls $Global:CurFolPath 72 | $listView.Clear() 73 | foreach ($Item in $Items) { 74 | if (!($Item -like "*.*")) { 75 | $ListItem = [ListViewItem]::new($Item, 0) 76 | $listView.Items.Add($ListItem) 77 | } 78 | 79 | else { 80 | $ListItem = [ListViewItem]::new($Item, 1) 81 | $listView.Items.Add($ListItem) 82 | } 83 | } 84 | $listView.Refresh() 85 | } 86 | ) 87 | 88 | $listViewWrapperPanel = [Panel]::new() 89 | $listViewWrapperPanel.Location = [Point]::new(50,50) 90 | $listViewWrapperPanel.Dock = "Fill" 91 | $listViewWrapperPanel.Padding = [Padding]::new(0) 92 | $listViewWrapperPanel.Controls.Add($listView) 93 | 94 | $mainMenuButton1 = [Button]::new() 95 | $mainMenuButton1.MinimumSize = [Size]::new(200,50) 96 | $mainMenuButton1.Text = "Browse Phone" 97 | 98 | $mainMenuButton2 = [Button]::new() 99 | $mainMenuButton2.MinimumSize = [Size]::new(200,50) 100 | $mainMenuButton2.Location = [Point]::new(0,50) 101 | $mainMenuButton2.Text = "Install Apk(s)" 102 | 103 | $mainMenuButton3 = [Button]::new() 104 | $mainMenuButton3.MinimumSize = [Size]::new(200,50) 105 | $mainMenuButton3.Location = [Point]::new(0,100) 106 | $mainMenuButton3.Text = "Get Apk Common Names" 107 | 108 | $mainMenu = [Panel]::new() 109 | $mainMenu.Margin = [Padding]::new(0,0,5,0) 110 | $mainMenu.Dock = "Left" 111 | $mainMenu.BackColor = [Color]::Black 112 | $mainMenu.ForeColor = [Color]::White 113 | $mainMenu.Controls.Add($mainMenuButton1) 114 | $mainMenu.Controls.Add($mainMenuButton2) 115 | $mainMenu.Controls.Add($mainMenuButton3) 116 | 117 | $page1BottomButton1 = [Button]::new() 118 | $page1BottomButton1.Dock = "Top" 119 | $page1BottomButton1.Text = "Select Folder To Transfer Files To" 120 | 121 | $page1BottomButton2 = [Button]::new() 122 | $page1BottomButton2.Dock = "top" 123 | $page1BottomButton2.Text = "Transfer To Current Directory" 124 | 125 | $page1BottomButton3 = [Button]::new() 126 | $page1BottomButton3.Dock = "Top" 127 | $page1BottomButton3.Text = "Transfer To Opposite Directory" 128 | 129 | $page1BottomButton4 = [Button]::new() 130 | $page1BottomButton4.Dock = "Top" 131 | $page1BottomButton4.Text = "Transfer Selected Files To Open Phone Directory" 132 | 133 | $page1BottomButton1.Add_Click( 134 | { 135 | $fbd = [FolderBrowserDialog]::new() 136 | $fbd.ShowDialog() 137 | Start-Sleep -Milliseconds 50 138 | $listView.SelectedItems.Text | ForEach-Object -Process { 139 | if ($_ -like "*.*") { 140 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial pull ($Global:CurFolPath + $_) $fbd.SelectedPath 141 | } 142 | else { 143 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial pull ($Global:CurFolPath + $_ + "/") $fbd.SelectedPath 144 | } 145 | } 146 | Start-Sleep -Milliseconds 50 147 | [MessageBox]::Show("All Files Have Transfered Successfully","Sucess!","Ok") 148 | } 149 | ) 150 | 151 | $page1BottomButton2.Add_Click( 152 | { 153 | $listView.SelectedItems.Text | ForEach-Object -Process { 154 | if ($_ -like "*.*") { 155 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial pull ($Global:CurFolPath + $_) $CurDir 156 | } 157 | else { 158 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial pull ($Global:CurFolPath + $_ + "/") $CurDir 159 | } 160 | } 161 | Start-Sleep -Milliseconds 50 162 | [MessageBox]::Show("All Files Have Transfered Successfully","Sucess!","Ok") 163 | } 164 | ) 165 | 166 | $page1BottomButton3.Add_Click( 167 | { 168 | $listView.SelectedItems.Text | ForEach-Object -Process { 169 | if ($_ -like "*.*") { 170 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial pull ($Global:CurFolPath + $_) $OpDir 171 | } 172 | else { 173 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial pull ($Global:CurFolPath + $_ + "/") $OpDir 174 | } 175 | } 176 | Start-Sleep -Milliseconds 50 177 | [MessageBox]::Show("All Files Have Transfered Successfully","Sucess!","Ok") 178 | } 179 | ) 180 | 181 | $page1BottomButton4.Add_Click( 182 | { 183 | Write-Host "In Button 4 Click" 184 | $SelectedItems 185 | $SelectedItems | ForEach-Object { 186 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial push $_ ($Global:CurFolPath + "/") 187 | } 188 | Start-Sleep -Milliseconds 50 189 | [MessageBox]::Show("All Files Have Transfered Successfully","Sucess!","Ok") 190 | } 191 | ) 192 | 193 | 194 | $page1BottomPanel = [Panel]::new() 195 | $page1BottomPanel.Dock = "Bottom" 196 | $page1BottomPanel.AutoSize = $true 197 | $page1BottomPanel.Controls.Add($page1BottomButton1) 198 | $page1BottomPanel.Controls.Add($page1BottomButton2) 199 | $page1BottomPanel.Controls.Add($page1BottomButton3) 200 | $page1BottomPanel.Controls.Add($page1BottomButton4) 201 | 202 | 203 | $page1Panel.Controls.Add($listViewWrapperPanel) 204 | $page1Panel.Controls.Add($page1MenuPanel) 205 | $page1Panel.Controls.Add($page1BottomPanel) 206 | 207 | 208 | $page2Button1 = [Button]::new() 209 | $page2Button1.AutoSize = $true 210 | $page2Button1.Dock = "Top" 211 | $page2Button1.Text = "Select Apke(s) To Install" 212 | 213 | $page2BottomPanelButton = [Button]::new() 214 | $page2BottomPanelButton.AutoSize = $true 215 | $page2BottomPanelButton.Dock = "Fill" 216 | $page2BottomPanelButton.Text = "Install Apk(s) To Connected Phone" 217 | 218 | $page2BottomPanel = [Panel]::new() 219 | $page2BottomPanel.Dock = "Bottom" 220 | $page2BottomPanel.Height = 100 221 | $page2BottomPanel.Controls.Add($page2BottomPanelButton) 222 | 223 | 224 | $page2ListBoxSelectedFiles = [listbox]::new() 225 | $page2ListBoxSelectedFiles.Dock = "Fill" 226 | $page2ListBoxSelectedFiles.Top = 50 227 | $page2ListBoxSelectedFiles.HorizontalScrollbar = $true 228 | $page2ListBoxSelectedFiles.Height = 700 229 | 230 | $page2FileSelectDialog = [OpenFileDialog]::new() 231 | $page2FileSelectDialog.Multiselect = $true 232 | 233 | $page2Panel.Controls.Add($page2ListBoxSelectedFiles) 234 | $page2Panel.Controls.Add($page2Button1) 235 | $page2Panel.Controls.Add($page2BottomPanel) 236 | 237 | 238 | 239 | $page1MenuButton1.Add_Click( 240 | { 241 | $Global:PrePath = $Global:CurFolPath 242 | if ($Global:PrePath -ne "/sdcard/") { 243 | $TempList = $Global:PrePath.Split('/', [StringSplitOptions]::RemoveEmptyEntries) 244 | $RepText = $TempList[-1] 245 | $Global:PrePath = ($Global:PrePath).Replace("$RepText/","") 246 | $Items = & "$PSScriptRoot\Tools\adb.exe" "-s" $SelectedADBSerial "shell" "ls" "$($Global:PrePath)" 247 | $Global:CurFolPath = $Global:PrePath 248 | $ListView.Clear() 249 | foreach ($Item in $Items) { 250 | if (!($Item -like "*.*")) { 251 | $ListItem = [ListViewItem]::new($Item, 0) 252 | $listView.Items.Add($ListItem) 253 | } 254 | 255 | else { 256 | $ListItem = [ListViewItem]::new($Item, 1) 257 | $listView.Items.Add($ListItem) 258 | } 259 | } 260 | $ListView.Refresh() 261 | } 262 | else { 263 | [MessageBox]::Show("You are already at top level!","No Further To Go!",[MessageBoxButtons]::OK) 264 | } 265 | } 266 | ) 267 | 268 | $page2Button1.Add_Click( 269 | { 270 | $results = $page2FileSelectDialog.ShowDialog() 271 | if ($results -eq "OK") { 272 | Write-Host "We're In!" 273 | $page2ListBoxSelectedFiles.Items.Clear() 274 | Start-Sleep -Milliseconds 50 275 | foreach ($File in $page2FileSelectDialog.FileNames) { 276 | $page2ListBoxSelectedFiles.Items.Add(($File)) 277 | } 278 | } 279 | else { 280 | Write-Host "Dialog Canceled" 281 | } 282 | 283 | } 284 | ) 285 | 286 | $page2BottomPanelButton.Add_Click( 287 | { 288 | foreach ($FileName in $page2FileSelectDialog.FileNames) { 289 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial install $FileName 290 | } 291 | [MessageBox]::Show("Apk(s) Sucessfully Installed","Sucess!","Ok") 292 | $page2ListBoxSelectedFiles.Items.Clear() 293 | } 294 | ) 295 | 296 | $mainMenuButton1.Add_Click( 297 | { 298 | $form.Controls.Clear() 299 | Start-Sleep -Milliseconds 50 300 | $form.Controls.Add($page1Panel) 301 | $form.Controls.Add($mainMenu) 302 | } 303 | ) 304 | 305 | $mainMenuButton2.Add_Click( 306 | { 307 | $form.Controls.Clear() 308 | Start-Sleep -Milliseconds 50 309 | $form.Controls.Add($page2Panel) 310 | $form.Controls.Add($mainMenu) 311 | } 312 | ) 313 | 314 | $mainMenuButton3.Add_Click( 315 | { 316 | $form.Controls.Clear() 317 | Start-Sleep -Milliseconds 50 318 | $form.Controls.Add($page3Panel) 319 | $form.Controls.Add($mainMenu) 320 | } 321 | ) 322 | 323 | $label = [Label]::new() 324 | $label.AutoSize = $true 325 | $label.Location =[Point]::new(100,25) 326 | $label.Text = "Select which packages to list" 327 | 328 | $checkbox1 = [CheckBox]::new() 329 | $checkbox1.AutoSize = $true 330 | $checkbox1.Location = [Point]::new(100, 50) 331 | $checkbox1.Text = "Third Party Packages" 332 | 333 | $checkbox2 = [CheckBox]::new() 334 | $checkbox2.AutoSize = $true 335 | $checkbox2.Location = [Point]::new(300, 50) 336 | $checkbox2.Text = "System Packages" 337 | 338 | $progressLabel1 = [Label]::new() 339 | $progressLabel1.AutoSize = $true 340 | $progressLabel1.Location = [Point]::new(100, 100) 341 | $progressLabel1.Text = "Apk Pulling Progress" 342 | 343 | $progressBar = [ProgressBar]::new() 344 | $progressBar.AutoSize = $true 345 | $progressBar.Location = [Point]::new(100, 150) 346 | $progressBar.Visible = $true 347 | $progressBar.Minimum = 1 348 | $progressBar.Value = 1 349 | 350 | $progressLabel2 = [Label]::new() 351 | $progressLabel2.AutoSize = $true 352 | $progressLabel2.Location = [Point]::new(300, 100) 353 | $progressLabel2.Text = "Apk Processing Progress" 354 | 355 | $progressBar2 = [ProgressBar]::new() 356 | $progressBar2.AutoSize = $true 357 | $progressBar2.Location = [Point]::new(300, 150) 358 | $progressBar2.Visible = $true 359 | $progressBar2.Minimum = 1 360 | $progressBar2.Value = 1 361 | 362 | $button = [Button]::new() 363 | $button.AutoSize = $true 364 | $button.Location = [Point]::new(100, 200) 365 | $button.Text = "OK" 366 | 367 | $listBoxLabel = [Label]::new() 368 | $listBoxLabel.AutoSize = $true 369 | $listBoxLabel.Location = [Point]::new(100, 250) 370 | $listBoxLabel.Text = "Select Apps From Results:" 371 | 372 | $resultsListBox = [ListBox]::new() 373 | $resultsListBox.AutoSize = $true 374 | $resultsListBox.Location = [Point]::new(100, 300) 375 | $resultsListBox.SelectionMode = "None" 376 | 377 | $rsultsListCheckBoxLabel = [Label]::new() 378 | $rsultsListCheckBoxLabel.AutoSize = $true 379 | $rsultsListCheckBoxLabel.Location = [Point]::new(100, 800) 380 | $rsultsListCheckBoxLabel.Text = "Select Action(s) To Take" 381 | 382 | $resultsCheckBox1 = [CheckBox]::new() 383 | $resultsCheckBox1.AutoSize = $true 384 | $resultsCheckBox1.Location = [Point]::new(100, 800) 385 | $resultsCheckBox1.Text = "Uninstall" 386 | 387 | $resultsCheckBox2 = [CheckBox]::new() 388 | $resultsCheckBox2.AutoSize = $true 389 | $resultsCheckBox2.Location = [Point]::new(200, 800) 390 | $resultsCheckBox2.Text = "Save Apks To Selected Location" 391 | 392 | $resultsCheckBox3 = [CheckBox]::new() 393 | $resultsCheckBox3.AutoSize = $true 394 | $resultsCheckBox3.Location = [Point]::new(500, 800) 395 | $resultsCheckBox3.Text = "Clear Cache" 396 | 397 | $resultsCheckBox4 = [CheckBox]::new() 398 | $resultsCheckBox4.AutoSize = $true 399 | $resultsCheckBox4.Location = [Point]::new(700, 800) 400 | $resultsCheckBox4.Text = "Clear Data" 401 | 402 | $resultsButton = [Button]::new() 403 | $resultsButton.AutoSize = $true 404 | $resultsButton.Location = [Point]::new(100, 850) 405 | $resultsButton.Text = "Clear Data" 406 | 407 | 408 | 409 | 410 | $button.Add_Click( 411 | { 412 | $Global:Args1 = @() 413 | if ($checkbox1.Checked -and $checkbox2.Checked) { 414 | $Global:Args1 = "shell", "pm", "list", "packages", "-a", "-f" 415 | } 416 | if ($checkbox1.Checked -and !($checkbox2.Checked)) { 417 | $Global:Args1 = "shell", "pm", "list", "packages", "-3", "-f" 418 | } 419 | if (!($checkbox1.Checked) -and $checkbox2.Checked) { 420 | $Global:Args1 = "shell", "pm", "list", "packages", "-s", "-f" 421 | } 422 | $NewLineSplitPackages = & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial @Args1 423 | $ParsedADBPaths = @() 424 | $ParsedADBPackageNames = @() 425 | foreach ($line in $NewLineSplitPackages) { 426 | $ParsedPath1 = ($line -replace '^package:' -replace '(?<=base\.apk).*') 427 | $PackageName = ($line -split "=")[-1].ToString() 428 | $ParsedADBPaths += $ParsedPath1 429 | $ParsedADBPackageNames += $PackageName 430 | } 431 | $progressBar.Maximum = $ParsedADBPaths.Count 432 | if (Test-Path "$PSScriptRoot\Export\ApkFiles\") { 433 | Remove-Item -Path "$PSScriptRoot\Export\ApkFiles\" -Recurse -Force 434 | } 435 | New-Item -Path "$PSScriptRoot\Export\ApkFiles\" -ItemType Directory -Force 436 | for ($i = 0; $i -lt $ParsedADBPaths.Count; $i++) { 437 | $Args2 = "pull", "$($ParsedADBPaths[$i])", "$PSScriptRoot\Export\ApkFiles\$($ParsedADBPackageNames[$i]).apk" 438 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial @Args2 439 | $progressBar.Increment(1) 440 | } 441 | $GetApks = Get-ChildItem -Path "$PSScriptRoot\Export\ApkFiles\" -File -Force 442 | $CommonNames = @{} 443 | $progressBar2.Maximum = $GetApks.Count 444 | foreach ($apk in $GetApks) { 445 | $Args3 = "dump", "badging", "$($apk.FullName)" 446 | $RawAAPT2Dump = & "$PSScriptRoot\Tools\aapt2.exe" @Args3 447 | $ParsedDump = $RawAAPT2Dump | Select-String "(?<=application-label:')[^']+" | ForEach-Object { $_.Matches.Value } 448 | $CommonNames.Add($apk.BaseName, $ParsedDump) 449 | $progressBar2.Increment(1) 450 | } 451 | Write-Host "Here 1" 452 | $SortedApksByCommonName = $CommonNames.GetEnumerator() | Sort-Object -Property Value 453 | Write-Host "Here 2" 454 | $Global:Results = $SortedApksByCommonName | Out-GridView -Title "Apks & Names" -OutputMode Multiple 455 | Write-Host "Here 3" 456 | 457 | 458 | foreach ($result in $Global:Results) { 459 | Write-Host "Here 4" 460 | $resultsListBox.Items.Add($result.Value) 461 | } 462 | } 463 | ) 464 | $resultsButton.Add_Click( 465 | { 466 | $SelectFolder = [FolderBrowserDialog]::new() 467 | foreach ($result in $Global:Results) { 468 | if ($resultsCheckBox1.Checked) { 469 | Write-Host "$($result.Key)" 470 | $uninstallArgs = "uninstall", "$($result.Key)" 471 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial @uninstallArgs 472 | } 473 | if ($resultsCheckBox2.Checked) { 474 | if ($SelectFolder.ShowDialog() -eq "OK") { 475 | $selectedFolder = $SelectFolder.SelectedPath 476 | Copy-Item -Path (Get-ChildItem -Path "$PSScriptRoot\Export\ApkFiles\$($result.Key).apk").FullName -Destination $selectedFolder 477 | } 478 | } 479 | if ($resultsCheckBox3.Checked) { 480 | $cacheArgs = '-d', 'shell', 'pm', 'clear', '--cache-only', "$($result.Key)" 481 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial @cacheArgs 482 | } 483 | if ($resultsCheckBox4) { 484 | $cacheArgs = '-d', 'shell', 'pm', 'clear', "$($result.Key)" 485 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial @cacheArgs 486 | } 487 | } 488 | } 489 | ) 490 | 491 | $page3Panel.Controls.Add($label) 492 | $page3Panel.Controls.Add($checkbox1) 493 | $page3Panel.Controls.Add($checkbox2) 494 | $page3Panel.Controls.Add($progressLabel1) 495 | $page3Panel.Controls.Add($progressLabel2) 496 | $page3Panel.Controls.Add($progressBar) 497 | $page3Panel.Controls.Add($progressBar2) 498 | $page3Panel.Controls.Add($button) 499 | $page3Panel.Controls.Add($listBoxLabel) 500 | $page3Panel.Controls.Add($resultsListBox) 501 | $page3Panel.Controls.Add($resultsCheckBox1) 502 | $page3Panel.Controls.Add($resultsCheckBox2) 503 | $page3Panel.Controls.Add($resultsCheckBox3) 504 | $page3Panel.Controls.Add($resultsCheckBox4) 505 | $page3Panel.Controls.Add($resultsButton) 506 | 507 | $form.Controls.Add($page1Panel) 508 | $form.Controls.Add($mainMenu) 509 | 510 | $form.ShowDialog() 511 | -------------------------------------------------------------------------------- /KK/AndroidADB/Launch-Phone-Gui-New.ps1: -------------------------------------------------------------------------------- 1 | #PS7 2 | using namespace System.Windows.Forms 3 | using namespace System.Drawing 4 | 5 | Add-Type -AssemblyName System.Windows.Forms 6 | Add-Type -AssemblyName System.Drawing 7 | 8 | $OCVars = Get-OCVars 9 | $CurDir = $OCVars.CurrentDir 10 | $OpDir = $OCVars.OpDir 11 | $SelectedItems = $OCVars.SelectedFiles -split "\n" 12 | 13 | $SelectedADBSerial = Get-ADBDevice 14 | 15 | adb kill-server 16 | 17 | $Global:CurFolPath = "/sdcard/" 18 | $adbInitFolders = & "$PSScriptRoot\Tools\adb.exe" "-s" $SelectedADBSerial "shell" "ls" "$($Global:CurFolPath)" 19 | 20 | $form = [Form]::new() 21 | $form.Size = [Size]::new(1000,900) 22 | $form.BackColor = [Color]::White 23 | $form.StartPosition = [FormStartPosition]::CenterScreen 24 | $form.Font = $DefaultFont.Font 25 | 26 | $page1MenuButton1Image = [Image]::FromFile("$PSScriptRoot\Assests\uparrow.png") 27 | 28 | $page1MenuButton1 = [Button]::new() 29 | $page1MenuButton1.Size = [Size]::new(50,50) 30 | $page1MenuButton1.Image = $page1MenuButton1Image 31 | 32 | $page1Panel = [Panel]::new() 33 | $page1Panel.Dock = [DockStyle]::Fill 34 | 35 | $page2Panel = [Panel]::new() 36 | $page2Panel.Dock = [DockStyle]::Fill 37 | 38 | $page3Panel = [Panel]::new() 39 | $page3Panel.Dock = [DockStyle]::Fill 40 | 41 | $page1MenuPanel = [Panel]::new() 42 | $page1MenuPanel.Dock = "Top" 43 | $page1MenuPanel.Height = 50 44 | $page1MenuPanel.BackColor = [Color]::Black 45 | $page1MenuPanel.Padding = [Padding]::new(0) 46 | $page1MenuPanel.Margin = [Padding]::new(0) 47 | $page1MenuPanel.Controls.Add($page1MenuButton1) 48 | 49 | 50 | $lvImageList = [ImageList]::new() 51 | $lvImageList.Images.Add([Image]::FromFile("$PSScriptRoot\Assests\folder.png")) 52 | $lvImageList.Images.Add([Image]::FromFile("$PSScriptRoot\Assests\file.png")) 53 | $lvImageList.ImageSize = [Size]::new(50,50) 54 | 55 | $listView = [ListView]::new() 56 | $listView.BorderStyle = [BorderStyle]::None 57 | $listView.Dock = [DockStyle]::Fill 58 | $listView.View = [View]::LargeIcon 59 | $listView.BackColor = [Color]::Black 60 | $listView.ForeColor = [Color]::White 61 | $listView.LargeImageList = $lvImageList 62 | foreach ($Item in $adbInitFolders) { 63 | $listView.Items.Add($Item,0) 64 | } 65 | 66 | $listView.Add_DoubleClick({ 67 | Write-Host "In The DoubleClick" 68 | Write-Host "$($listView.SelectedItems[0].Text)" 69 | $Folder = $listView.SelectedItems[0].Text 70 | $Global:CurFolPath = $Global:CurFolPath + $Folder + "/" 71 | $Items = adb -s $SelectedADBSerial shell ls $Global:CurFolPath 72 | $listView.Clear() 73 | foreach ($Item in $Items) { 74 | if (!($Item -like "*.*")) { 75 | $ListItem = [ListViewItem]::new($Item, 0) 76 | $listView.Items.Add($ListItem) 77 | } 78 | 79 | else { 80 | $ListItem = [ListViewItem]::new($Item, 1) 81 | $listView.Items.Add($ListItem) 82 | } 83 | } 84 | $listView.Refresh() 85 | } 86 | ) 87 | 88 | $listViewWrapperPanel = [Panel]::new() 89 | $listViewWrapperPanel.Location = [Point]::new(50,50) 90 | $listViewWrapperPanel.Dock = "Fill" 91 | $listViewWrapperPanel.Padding = [Padding]::new(0) 92 | $listViewWrapperPanel.Controls.Add($listView) 93 | 94 | $mainMenuButton1 = [Button]::new() 95 | $mainMenuButton1.MinimumSize = [Size]::new(200,50) 96 | $mainMenuButton1.Text = "Browse Phone" 97 | 98 | $mainMenuButton2 = [Button]::new() 99 | $mainMenuButton2.MinimumSize = [Size]::new(200,50) 100 | $mainMenuButton2.Location = [Point]::new(0,50) 101 | $mainMenuButton2.Text = "Install Apk(s)" 102 | 103 | $mainMenuButton3 = [Button]::new() 104 | $mainMenuButton3.MinimumSize = [Size]::new(200,50) 105 | $mainMenuButton3.Location = [Point]::new(0,100) 106 | $mainMenuButton3.Text = "Get Apk Common Names" 107 | 108 | $mainMenu = [Panel]::new() 109 | $mainMenu.Margin = [Padding]::new(0,0,5,0) 110 | $mainMenu.Dock = "Left" 111 | $mainMenu.BackColor = [Color]::Black 112 | $mainMenu.ForeColor = [Color]::White 113 | $mainMenu.Controls.Add($mainMenuButton1) 114 | $mainMenu.Controls.Add($mainMenuButton2) 115 | $mainMenu.Controls.Add($mainMenuButton3) 116 | 117 | $page1BottomButton1 = [Button]::new() 118 | $page1BottomButton1.Dock = "Top" 119 | $page1BottomButton1.Text = "Select Folder To Transfer Files To" 120 | 121 | $page1BottomButton2 = [Button]::new() 122 | $page1BottomButton2.Dock = "top" 123 | $page1BottomButton2.Text = "Transfer To Current Directory" 124 | 125 | $page1BottomButton3 = [Button]::new() 126 | $page1BottomButton3.Dock = "Top" 127 | $page1BottomButton3.Text = "Transfer To Opposite Directory" 128 | 129 | $page1BottomButton4 = [Button]::new() 130 | $page1BottomButton4.Dock = "Top" 131 | $page1BottomButton4.Text = "Transfer Selected Files To Open Phone Directory" 132 | 133 | $page1BottomButton1.Add_Click( 134 | { 135 | $fbd = [FolderBrowserDialog]::new() 136 | $fbd.ShowDialog() 137 | Start-Sleep -Milliseconds 50 138 | $listView.SelectedItems.Text | ForEach-Object -Process { 139 | if ($_ -like "*.*") { 140 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial pull ($Global:CurFolPath + $_) $fbd.SelectedPath 141 | } 142 | else { 143 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial pull ($Global:CurFolPath + $_ + "/") $fbd.SelectedPath 144 | } 145 | } 146 | Start-Sleep -Milliseconds 50 147 | [MessageBox]::Show("All Files Have Transfered Successfully","Sucess!","Ok") 148 | } 149 | ) 150 | 151 | $page1BottomButton2.Add_Click( 152 | { 153 | $listView.SelectedItems.Text | ForEach-Object -Process { 154 | if ($_ -like "*.*") { 155 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial pull ($Global:CurFolPath + $_) $CurDir 156 | } 157 | else { 158 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial pull ($Global:CurFolPath + $_ + "/") $CurDir 159 | } 160 | } 161 | Start-Sleep -Milliseconds 50 162 | [MessageBox]::Show("All Files Have Transfered Successfully","Sucess!","Ok") 163 | } 164 | ) 165 | 166 | $page1BottomButton3.Add_Click( 167 | { 168 | $listView.SelectedItems.Text | ForEach-Object -Process { 169 | if ($_ -like "*.*") { 170 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial pull ($Global:CurFolPath + $_) $OpDir 171 | } 172 | else { 173 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial pull ($Global:CurFolPath + $_ + "/") $OpDir 174 | } 175 | } 176 | Start-Sleep -Milliseconds 50 177 | [MessageBox]::Show("All Files Have Transfered Successfully","Sucess!","Ok") 178 | } 179 | ) 180 | 181 | $page1BottomButton4.Add_Click( 182 | { 183 | Write-Host "In Button 4 Click" 184 | $SelectedItems 185 | $SelectedItems | ForEach-Object { 186 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial push $_ ($Global:CurFolPath + "/") 187 | } 188 | Start-Sleep -Milliseconds 50 189 | [MessageBox]::Show("All Files Have Transfered Successfully","Sucess!","Ok") 190 | } 191 | ) 192 | 193 | 194 | $page1BottomPanel = [Panel]::new() 195 | $page1BottomPanel.Dock = "Bottom" 196 | $page1BottomPanel.AutoSize = $true 197 | $page1BottomPanel.Controls.Add($page1BottomButton1) 198 | $page1BottomPanel.Controls.Add($page1BottomButton2) 199 | $page1BottomPanel.Controls.Add($page1BottomButton3) 200 | $page1BottomPanel.Controls.Add($page1BottomButton4) 201 | 202 | 203 | $page1Panel.Controls.Add($listViewWrapperPanel) 204 | $page1Panel.Controls.Add($page1MenuPanel) 205 | $page1Panel.Controls.Add($page1BottomPanel) 206 | 207 | 208 | $page2Button1 = [Button]::new() 209 | $page2Button1.AutoSize = $true 210 | $page2Button1.Dock = "Top" 211 | $page2Button1.Text = "Select Apke(s) To Install" 212 | 213 | $page2BottomPanelButton = [Button]::new() 214 | $page2BottomPanelButton.AutoSize = $true 215 | $page2BottomPanelButton.Dock = "Fill" 216 | $page2BottomPanelButton.Text = "Install Apk(s) To Connected Phone" 217 | 218 | $page2BottomPanel = [Panel]::new() 219 | $page2BottomPanel.Dock = "Bottom" 220 | $page2BottomPanel.Height = 100 221 | $page2BottomPanel.Controls.Add($page2BottomPanelButton) 222 | 223 | 224 | $page2ListBoxSelectedFiles = [listbox]::new() 225 | $page2ListBoxSelectedFiles.Dock = "Fill" 226 | $page2ListBoxSelectedFiles.Top = 50 227 | $page2ListBoxSelectedFiles.HorizontalScrollbar = $true 228 | $page2ListBoxSelectedFiles.Height = 700 229 | 230 | $page2FileSelectDialog = [OpenFileDialog]::new() 231 | $page2FileSelectDialog.Multiselect = $true 232 | 233 | $page2Panel.Controls.Add($page2ListBoxSelectedFiles) 234 | $page2Panel.Controls.Add($page2Button1) 235 | $page2Panel.Controls.Add($page2BottomPanel) 236 | 237 | 238 | 239 | $page1MenuButton1.Add_Click( 240 | { 241 | $Global:PrePath = $Global:CurFolPath 242 | if ($Global:PrePath -ne "/sdcard/") { 243 | $TempList = $Global:PrePath.Split('/', [StringSplitOptions]::RemoveEmptyEntries) 244 | $RepText = $TempList[-1] 245 | $Global:PrePath = ($Global:PrePath).Replace("$RepText/","") 246 | $Items = & "$PSScriptRoot\Tools\adb.exe" "-s" $SelectedADBSerial "shell" "ls" "$($Global:PrePath)" 247 | $Global:CurFolPath = $Global:PrePath 248 | $ListView.Clear() 249 | foreach ($Item in $Items) { 250 | if (!($Item -like "*.*")) { 251 | $ListItem = [ListViewItem]::new($Item, 0) 252 | $listView.Items.Add($ListItem) 253 | } 254 | 255 | else { 256 | $ListItem = [ListViewItem]::new($Item, 1) 257 | $listView.Items.Add($ListItem) 258 | } 259 | } 260 | $ListView.Refresh() 261 | } 262 | else { 263 | [MessageBox]::Show("You are already at top level!","No Further To Go!",[MessageBoxButtons]::OK) 264 | } 265 | } 266 | ) 267 | 268 | $page2Button1.Add_Click( 269 | { 270 | $results = $page2FileSelectDialog.ShowDialog() 271 | if ($results -eq "OK") { 272 | Write-Host "We're In!" 273 | $page2ListBoxSelectedFiles.Items.Clear() 274 | Start-Sleep -Milliseconds 50 275 | foreach ($File in $page2FileSelectDialog.FileNames) { 276 | $page2ListBoxSelectedFiles.Items.Add(($File)) 277 | } 278 | } 279 | else { 280 | Write-Host "Dialog Canceled" 281 | } 282 | 283 | } 284 | ) 285 | 286 | $page2BottomPanelButton.Add_Click( 287 | { 288 | foreach ($FileName in $page2FileSelectDialog.FileNames) { 289 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial install $FileName 290 | } 291 | [MessageBox]::Show("Apk(s) Sucessfully Installed","Sucess!","Ok") 292 | $page2ListBoxSelectedFiles.Items.Clear() 293 | } 294 | ) 295 | 296 | $mainMenuButton1.Add_Click( 297 | { 298 | $form.Controls.Clear() 299 | Start-Sleep -Milliseconds 50 300 | $form.Controls.Add($page1Panel) 301 | $form.Controls.Add($mainMenu) 302 | } 303 | ) 304 | 305 | $mainMenuButton2.Add_Click( 306 | { 307 | $form.Controls.Clear() 308 | Start-Sleep -Milliseconds 50 309 | $form.Controls.Add($page2Panel) 310 | $form.Controls.Add($mainMenu) 311 | } 312 | ) 313 | 314 | $mainMenuButton3.Add_Click( 315 | { 316 | $form.Controls.Clear() 317 | Start-Sleep -Milliseconds 50 318 | $form.Controls.Add($page3Panel) 319 | $form.Controls.Add($mainMenu) 320 | } 321 | ) 322 | 323 | $label = [Label]::new() 324 | $label.AutoSize = $true 325 | $label.Location =[Point]::new(100,25) 326 | $label.Text = "Select which packages to list" 327 | 328 | $checkbox1 = [CheckBox]::new() 329 | $checkbox1.AutoSize = $true 330 | $checkbox1.Location = [Point]::new(100, 50) 331 | $checkbox1.Text = "Third Party Packages" 332 | 333 | $checkbox2 = [CheckBox]::new() 334 | $checkbox2.AutoSize = $true 335 | $checkbox2.Location = [Point]::new(300, 50) 336 | $checkbox2.Text = "System Packages" 337 | 338 | $progressLabel1 = [Label]::new() 339 | $progressLabel1.AutoSize = $true 340 | $progressLabel1.Location = [Point]::new(100, 100) 341 | $progressLabel1.Text = "Apk Pulling Progress" 342 | 343 | $progressBar = [ProgressBar]::new() 344 | $progressBar.AutoSize = $true 345 | $progressBar.Location = [Point]::new(100, 150) 346 | $progressBar.Visible = $true 347 | $progressBar.Minimum = 1 348 | $progressBar.Value = 1 349 | 350 | $progressLabel2 = [Label]::new() 351 | $progressLabel2.AutoSize = $true 352 | $progressLabel2.Location = [Point]::new(300, 100) 353 | $progressLabel2.Text = "Apk Processing Progress" 354 | 355 | $progressBar2 = [ProgressBar]::new() 356 | $progressBar2.AutoSize = $true 357 | $progressBar2.Location = [Point]::new(300, 150) 358 | $progressBar2.Visible = $true 359 | $progressBar2.Minimum = 1 360 | $progressBar2.Value = 1 361 | 362 | $button = [Button]::new() 363 | $button.AutoSize = $true 364 | $button.Location = [Point]::new(100, 200) 365 | $button.Text = "OK" 366 | 367 | $listBoxLabel = [Label]::new() 368 | $listBoxLabel.AutoSize = $true 369 | $listBoxLabel.Location = [Point]::new(100, 250) 370 | $listBoxLabel.Text = "Select Apps From Results:" 371 | 372 | $resultsListBox = [ListBox]::new() 373 | $resultsListBox.AutoSize = $true 374 | $resultsListBox.Location = [Point]::new(100, 300) 375 | $resultsListBox.SelectionMode = "None" 376 | 377 | $rsultsListCheckBoxLabel = [Label]::new() 378 | $rsultsListCheckBoxLabel.AutoSize = $true 379 | $rsultsListCheckBoxLabel.Location = [Point]::new(100, 800) 380 | $rsultsListCheckBoxLabel.Text = "Select Action(s) To Take" 381 | 382 | $resultsCheckBox1 = [CheckBox]::new() 383 | $resultsCheckBox1.AutoSize = $true 384 | $resultsCheckBox1.Location = [Point]::new(100, 800) 385 | $resultsCheckBox1.Text = "Uninstall" 386 | 387 | $resultsCheckBox2 = [CheckBox]::new() 388 | $resultsCheckBox2.AutoSize = $true 389 | $resultsCheckBox2.Location = [Point]::new(200, 800) 390 | $resultsCheckBox2.Text = "Save Apks To Selected Location" 391 | 392 | $resultsCheckBox3 = [CheckBox]::new() 393 | $resultsCheckBox3.AutoSize = $true 394 | $resultsCheckBox3.Location = [Point]::new(500, 800) 395 | $resultsCheckBox3.Text = "Clear Cache" 396 | 397 | $resultsCheckBox4 = [CheckBox]::new() 398 | $resultsCheckBox4.AutoSize = $true 399 | $resultsCheckBox4.Location = [Point]::new(700, 800) 400 | $resultsCheckBox4.Text = "Clear Data" 401 | 402 | $resultsButton = [Button]::new() 403 | $resultsButton.AutoSize = $true 404 | $resultsButton.Location = [Point]::new(100, 850) 405 | $resultsButton.Text = "Clear Data" 406 | 407 | 408 | 409 | 410 | $button.Add_Click( 411 | { 412 | $Global:Args1 = @() 413 | if ($checkbox1.Checked -and $checkbox2.Checked) { 414 | $Global:Args1 = "shell", "pm", "list", "packages", "-a", "-f" 415 | } 416 | if ($checkbox1.Checked -and !($checkbox2.Checked)) { 417 | $Global:Args1 = "shell", "pm", "list", "packages", "-3", "-f" 418 | } 419 | if (!($checkbox1.Checked) -and $checkbox2.Checked) { 420 | $Global:Args1 = "shell", "pm", "list", "packages", "-s", "-f" 421 | } 422 | $NewLineSplitPackages = & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial @Args1 423 | $ParsedADBPaths = @() 424 | $ParsedADBPackageNames = @() 425 | foreach ($line in $NewLineSplitPackages) { 426 | $ParsedPath1 = ($line -replace '^package:' -replace '(?<=base\.apk).*') 427 | $PackageName = ($line -split "=")[-1].ToString() 428 | $ParsedADBPaths += $ParsedPath1 429 | $ParsedADBPackageNames += $PackageName 430 | } 431 | $progressBar.Maximum = $ParsedADBPaths.Count 432 | if (Test-Path "$PSScriptRoot\Export\ApkFiles\") { 433 | Remove-Item -Path "$PSScriptRoot\Export\ApkFiles\" -Recurse -Force 434 | } 435 | New-Item -Path "$PSScriptRoot\Export\ApkFiles\" -ItemType Directory -Force 436 | for ($i = 0; $i -lt $ParsedADBPaths.Count; $i++) { 437 | $Args2 = "pull", "$($ParsedADBPaths[$i])", "$PSScriptRoot\Export\ApkFiles\$($ParsedADBPackageNames[$i]).apk" 438 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial @Args2 439 | $progressBar.Increment(1) 440 | } 441 | $GetApks = Get-ChildItem -Path "$PSScriptRoot\Export\ApkFiles\" -File -Force 442 | $CommonNames = @{} 443 | $progressBar2.Maximum = $GetApks.Count 444 | foreach ($apk in $GetApks) { 445 | $Args3 = "dump", "badging", "$($apk.FullName)" 446 | $RawAAPT2Dump = & "$PSScriptRoot\Tools\aapt2.exe" @Args3 447 | $ParsedDump = $RawAAPT2Dump | Select-String "(?<=application-label:')[^']+" | ForEach-Object { $_.Matches.Value } 448 | $CommonNames.Add($apk.BaseName, $ParsedDump) 449 | $progressBar2.Increment(1) 450 | } 451 | Write-Host "Here 1" 452 | $SortedApksByCommonName = $CommonNames.GetEnumerator() | Sort-Object -Property Value 453 | Write-Host "Here 2" 454 | $Global:Results = $SortedApksByCommonName | Out-GridView -Title "Apks & Names" -OutputMode Multiple 455 | Write-Host "Here 3" 456 | 457 | 458 | foreach ($result in $Global:Results) { 459 | Write-Host "Here 4" 460 | $resultsListBox.Items.Add($result.Value) 461 | } 462 | } 463 | ) 464 | $resultsButton.Add_Click( 465 | { 466 | $SelectFolder = [FolderBrowserDialog]::new() 467 | foreach ($result in $Global:Results) { 468 | if ($resultsCheckBox1.Checked) { 469 | Write-Host "$($result.Key)" 470 | $uninstallArgs = "uninstall", "$($result.Key)" 471 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial @uninstallArgs 472 | } 473 | if ($resultsCheckBox2.Checked) { 474 | if ($SelectFolder.ShowDialog() -eq "OK") { 475 | $selectedFolder = $SelectFolder.SelectedPath 476 | Copy-Item -Path (Get-ChildItem -Path "$PSScriptRoot\Export\ApkFiles\$($result.Key).apk").FullName -Destination $selectedFolder 477 | } 478 | } 479 | if ($resultsCheckBox3.Checked) { 480 | $cacheArgs = '-d', 'shell', 'pm', 'clear', '--cache-only', "$($result.Key)" 481 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial @cacheArgs 482 | } 483 | if ($resultsCheckBox4) { 484 | $cacheArgs = '-d', 'shell', 'pm', 'clear', "$($result.Key)" 485 | & "$PSScriptRoot\Tools\adb.exe" -s $SelectedADBSerial @cacheArgs 486 | } 487 | } 488 | } 489 | ) 490 | 491 | $page3Panel.Controls.Add($label) 492 | $page3Panel.Controls.Add($checkbox1) 493 | $page3Panel.Controls.Add($checkbox2) 494 | $page3Panel.Controls.Add($progressLabel1) 495 | $page3Panel.Controls.Add($progressLabel2) 496 | $page3Panel.Controls.Add($progressBar) 497 | $page3Panel.Controls.Add($progressBar2) 498 | $page3Panel.Controls.Add($button) 499 | $page3Panel.Controls.Add($listBoxLabel) 500 | $page3Panel.Controls.Add($resultsListBox) 501 | $page3Panel.Controls.Add($resultsCheckBox1) 502 | $page3Panel.Controls.Add($resultsCheckBox2) 503 | $page3Panel.Controls.Add($resultsCheckBox3) 504 | $page3Panel.Controls.Add($resultsCheckBox4) 505 | $page3Panel.Controls.Add($resultsButton) 506 | 507 | $form.Controls.Add($page1Panel) 508 | $form.Controls.Add($mainMenu) 509 | 510 | $form.ShowDialog() 511 | --------------------------------------------------------------------------------