Cleanning tmp files - Windows 11

Hi!
So if you want to clean you PC from all tmp files just do this, open cmd as administrator, copy this lines and paste in cmd, press enter!
Spoiler: CODE
Code:
del /F /S /Q %SystemDrive%\temp\* >%userprofile%\Desktop\DelTempLog.txt
del /F /S /Q %allusersprofile%\AppData\Local\Temp\* >>%userprofile%\Desktop\DelTempLog.txt
del /F /S /Q %userprofile%\AppData\Local\Temp\* >>%userprofile%\Desktop\DelTempLog.txt
del /F /S /Q %temp%\* >>%userprofile%\Desktop\DelTempLog.txt
del /F /S /Q %systemroot%\temp\* >>%userprofile%\Desktop\DelTempLog.txt
del /F /S /Q %systemroot%\assembly\tmp\* >>%userprofile%\Desktop\DelTempLog.txt
del /F /S /Q %systemroot%\System32\Temp\* >>%userprofile%\Desktop\DelTempLog.txt
del /F /S /Q %systemroot%\Prefetch\* >>%userprofile%\Desktop\DelTempLog.txt
del /f /s /q %systemdrive%\*.tmp >>%userprofile%\Desktop\DelTempLog.txt
del /f /s /q %systemdrive%\*\*.tmp >>%userprofile%\Desktop\DelTempLog.txt
del /f /s /q %systemdrive%\*\*\*.tmp >>%userprofile%\Desktop\DelTempLog.txt
del /f /s /q %systemdrive%\*\*\*\*.tmp >>%userprofile%\Desktop\DelTempLog.txt
del /f /s /q %systemdrive%\*\*\*\*\*.tmp >>%userprofile%\Desktop\DelTempLog.txt
del /f /s /q %systemdrive%\*\*\*\*\*\*.tmp >>%userprofile%\Desktop\DelTempLog.txt
del /f /s /q %systemdrive%\*\*\*\*\*\*\*.tmp >>%userprofile%\Desktop\DelTempLog.txt
@echo. & @echo Deleting Temporary Internet Files
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 >>%userprofile%\Desktop\DelTempLog.txt
@echo. & @echo Deleting Cookies...
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2 >>%userprofile%\Desktop\DelTempLog.txt
You will get DelTempLog.txt log on desktop.
I hope this helps you!

persona78 said:
Hi!
So if you want to clean you PC from all tmp files just do this, open cmd as administrator, copy this lines and paste in cmd, press enter!
Spoiler: CODE
Code:
del /F /S /Q %SystemDrive%\temp\* >%userprofile%\Desktop\DelTempLog.txt
del /F /S /Q %allusersprofile%\AppData\Local\Temp\* >>%userprofile%\Desktop\DelTempLog.txt
del /F /S /Q %userprofile%\AppData\Local\Temp\* >>%userprofile%\Desktop\DelTempLog.txt
del /F /S /Q %temp%\* >>%userprofile%\Desktop\DelTempLog.txt
del /F /S /Q %systemroot%\temp\* >>%userprofile%\Desktop\DelTempLog.txt
del /F /S /Q %systemroot%\assembly\tmp\* >>%userprofile%\Desktop\DelTempLog.txt
del /F /S /Q %systemroot%\System32\Temp\* >>%userprofile%\Desktop\DelTempLog.txt
del /F /S /Q %systemroot%\Prefetch\* >>%userprofile%\Desktop\DelTempLog.txt
del /f /s /q %systemdrive%\*.tmp >>%userprofile%\Desktop\DelTempLog.txt
del /f /s /q %systemdrive%\*\*.tmp >>%userprofile%\Desktop\DelTempLog.txt
del /f /s /q %systemdrive%\*\*\*.tmp >>%userprofile%\Desktop\DelTempLog.txt
del /f /s /q %systemdrive%\*\*\*\*.tmp >>%userprofile%\Desktop\DelTempLog.txt
del /f /s /q %systemdrive%\*\*\*\*\*.tmp >>%userprofile%\Desktop\DelTempLog.txt
del /f /s /q %systemdrive%\*\*\*\*\*\*.tmp >>%userprofile%\Desktop\DelTempLog.txt
del /f /s /q %systemdrive%\*\*\*\*\*\*\*.tmp >>%userprofile%\Desktop\DelTempLog.txt
@echo. & @echo Deleting Temporary Internet Files
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 >>%userprofile%\Desktop\DelTempLog.txt
@echo. & @echo Deleting Cookies...
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2 >>%userprofile%\Desktop\DelTempLog.txt
You will get DelTempLog.txt log on desktop.
I hope this helps you!
Click to expand...
Click to collapse
Thank you for taking the time to show us all that you have!!! I love how you showed us how to over come the user id while in script! I look forward to anything else you share :>

Related

Xperia neo v wont boot (NO LED,NOTHING) after testpoint

I follow the procedure i have found here in xda...All seemed to be ok and i download fastboot found in an other site for my bad luck.I run the command that i found here but i get command not found.
AND for my bad luck again i run this script
Code:
cls
@echo off
color 7
if not exist "fastboot.exe" cd fastboot
if not exist "fastboot.exe" cd C:\Fastboot\fastboot
if not exist "fastboot.exe" cd C:\Fastboot
set myvar=""
FOR /F "tokens=1 delims=&" %%i in ('fastboot devices') do SET myvar=%%i
if not %myvar%=="" goto UL
@color C
@echo.
@echo Es wurde KEIN Geraet mit entsperrbarem Bootloader erkannt!
@echo.
@pause
@goto END
:UL
@color A
@echo.
@echo %myvar%
@echo Bootloader entsperrbar!
@echo.
@pause
fastboot reboot
:END
cd..
@color 7
cls
After that i opened s1tool and i connect the phone with "back+power" and i pressed restore.
After that mobile stop boot at all.no led,nothing.i have this mobile for only 1 week,and im so sad........
Please help me...How can i make it functional again?

[DOS Util][Symlink code generator script]

DOS Script for creating SYMLINK code for updater-script
After searching and searching I found an usefull script for auto symlink text generation. One can use it with kitchen....
I modified it and put together in a single batch file.
It grabs APK list in directory you want (lets say C:\cygwin\home\user\kitchen\WORKING_030413_160037\preload\symlink\system\app)
and creates code and saves it to symlinks.txt
You can just copy-paste it in updater-script:
(rename sym_create.txt into sym_create.cmd)
Syntax is simple:
sym_create.cmd path_of_the_kitchen_working_directory_with_app_list
you get....
symlink("/preload/symlink/system/app/aplication_name.apk","/system/app/aplication_name.apk")
in symlinks.txt
Script:
Code:
@echo Listing APKs]
@echo .
@echo Choosen path = %1
for /r %1 %%g in (*.apk) do echo %%~nxg >> list.txt
@echo .
@echo [Preparing links]
echo .
for /f "tokens=*" %%A in (list.txt) do (echo.symlink("/preload/symlink/system/app/%%~nA.apk","/system/app/%%~nA.apk"^); >> symlinks.txt
)
I hope it saves you some time!
Sweet!
klemenSLO said:
DOS Script for creating SYMLINK code for updater-script
After searching and searching I found an usefull script for auto symlink text generation. One can use it with kitchen....
I modified it and put together in a single batch file.
It grabs APK list in directory you want (lets say C:\cygwin\home\user\kitchen\WORKING_030413_160037\preload\symlink\system\app)
and creates code and saves it to symlinks.txt
You can just copy-paste it in updater-script:
(rename sym_create.txt into sym_create.cmd)
Syntax is simple:
sym_create.cmd path_of_the_kitchen_working_directory_with_app_list
you get....
symlink("/preload/symlink/system/app/aplication_name.apk","/system/app/aplication_name.apk")
in symlinks.txt
Script:
Code:
@echo Listing APKs]
@echo .
@echo Choosen path = %1
for /r %1 %%g in (*.apk) do echo %%~nxg >> list.txt
@echo .
@echo [Preparing links]
echo .
for /f "tokens=*" %%A in (list.txt) do (echo.symlink("/preload/symlink/system/app/%%~nA.apk","/system/app/%%~nA.apk"^); >> symlinks.txt
)
I hope it saves you some time!
Click to expand...
Click to collapse
THANKS!!!!
Doing that by hand was REALLY getting old!!!
Mega Thanks

Dear Experts in ADB and Fastboot plz help..

hi.. all..
I am stuck in bootloop after failed system update.. there's no stock rom and no custom recovery available..
device is coolpad dazen 1 (8297L-100)
I have dumped system.img , boot.img and recovery.img
i want to restore system.img but fastboot flash command does not work always show... waiting for device..
but this script works..
taskkill /f /im "adb.exe" >nul 2>nul
taskkill /f /im "tadb.exe" >nul 2>nul
taskkill /f /fi "imagename eq wandoujia*" >nul 2>nul
taskkill /f /im "AndroidInterface.exe" >nul 2>nul
taskkill /f /im "Android PC Suite.exe" >nul 2>nul
taskkill /f /im "360MobileMgr.exe" >nul 2>nul
taskkill /f /im "qitu_adb.exe" >nul 2>nul
echo. Tat nguon, an giu Volume+ dong thoi cam cap USB
adb An nut Volume+
adb reboot bootloader
fastboot oem unlock
fastboot boot recovery_7to.img
ping -n 12 127.0>nul
adb push recovery_7to.img /tmp/
echo.
echo.
adb shell "dd if=/tmp/recovery_7to.img of=/dev/block/mmcblk0p28"
adb shell "rm -r /tmp/recovery_7to.img"
adb kill-server >nul 2>nul
pause>nul
goto MENU
i had used this script to boot in recovery temporarily when i was stuck in bootloader..
can i use this script with some changes to flash system.img.
i don't remember which partition was system /dev/block/mmcblk0p26 or 25 or somthing.
will it require flash_image file..
thanks.. plz reply...

Problem of the tutorial: formatting the SD Card into Internal Storage

Hello everyone,
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I've recently checked a tutorial about the auto-formatting the sd card into internal storage since I don't have space in my storage anymore.
https://forum.xda-developers.com/android/software/auto-formatting-sdcard-to-internal-t3583875
I did all instructions, but to the last part with the command "sm partition disk 179:194 private (or mixed 50)" it shows an error message.
You can find what I followed to the link I've put up there, and I'll ask two questions:
1. How can I do the auto-formatting with aftiss.cmd?
2. How can I fix this error message?
I hope that we'll be able to find a solution to this problem ^^
(PS: for anyone who asks "Why don't you go to the SD card and format as internal directly?" WELL, it's just that I don't have this option, I got a Huawei P8 Lite version, PRA-LX1)
May be on your phone it's not allowed the SD card to be formatted as internal memory.
Guess I have to buy another SD card then :/
But I'll wait for some other comment and see what they will say
Kaguma said:
Guess I have to buy another SD card then :/
But I'll wait for some other comment and see what they will say
Click to expand...
Click to collapse
Simply run
Code:
adb shell
sm has-adoptable
to see whether "false" or "true" is returned.
If it's "false", is there a way to put it on "true"?
Kaguma said:
If it's "false", is there a way to put it on "true"?
Click to expand...
Click to collapse
Buy a phone that supports it.
But except of having another phone, can't I put it on "true" even with my actual phone? There isn't a way at all?
@Kaguma
Here a small Windows command script that shows all the steps to be performed to transform an external SD-card into internal memory
Important: This is not tested so be aware of potential mistakes
Code:
rem (c) 2020 [email protected] Licensed under GPL v3
@echo OFF & setlocal ENABLEDELAYEDEXPANSION
echo FORMATTING EXTERNAL SD-CARD TO BE USED AS INTERNAL MEMORY ...
set "retval="
set /a device_connected=0
for /f "tokens=*" %%a in ('adb devices') do (
set "retval=%%a"
if NOT [!retva!]==[] (
echo !retval! | findstr /C:":" >nul
if !errorlevel! EQU 0 (set /a device_connected=1 )
)
)
if !device_connected! EQU 0 ( echo NO ANDROID DEVICE CONNECTED & goto :end )
set /a adoptable_sd_memory_is_supported=0
for /f "tokens=*" %%a in ('adb shell "sm has-adoptable"') do (
set "retval=%%a"
if NOT [!retval!]==[] (
echo !retval! | findstr /I /C:"true" >nul
if !errorlevel! EQU 0 ( set /a adoptable_sd_memory_is_supported=1 )
)
)
if !adoptable_sd_memory_is_supported! EQU 0 ( echo FEATURE ADOPTABLE MEMORY NOT SUPPORTED & goto :end )
set "private_sd_card_partition="
for /f "tokens=*" %%a in ('adb shell "sm list-disks adoptable"') do (
set "retval=%%a"
if NOT [!retval!]==[] (
echo !retval! | findstr /C:"disk:" >nul
if !errorlevel! EQU 0 ( set "private_sd_card_partition=!retval!" )
)
)
if [!private_sd_card_partition!]==[] ( echo NO MOUNTABLE SD-CARD PARTITION FOUND & goto :end )
rem
rem Depending on ROM instead of e.g. 179,128 obviously 179_128 must be used
rem If so, uncomment next command line
rem
rem set "private_sd_card_partition=!private_sd_card_partition:,=_!"
echo TRANSFORMING WHOLE EXTERNAL SD-CARD INTO INTERNAL MEMORY ...
echo IT TAKES TIME. BE PATIENT.
adb shell "sm set-force-adoptable true" >nul 2>nul
adb shell "sm partition !private_sd_card_partition! private" >nul 2>nul
adb shell "sm set-force-adoptable false" >nul 2>nul
echo DEVICE NOW GETS RE-BOOTED: DON'T UNPLUG SD-CARD.
adb reboot
adb wait-for-device >nul
:check_for_device_has_booted
for /f "tokens=*" %%a in ('adb shell "getprop sys.boot_completed"') do (
set "retval=%%a"
if NOT [!retval!]==[] (
echo !retval! | findstr /C:"1" >nul
if !errorlevel! EQU 0 ( goto :done_check_for_device_has_booted )
)
)
timeout /t 10 /nobreak >nul
goto :check_for_device_has_booted
:done_check_for_device_has_booted
set /a adoptable_storage_created=1
for /f "tokens=*" %%a in ('adb shell "sm list-volumes all"') do (
set "retval=%%a"
if NOT [!retval!]==[] (
echo !retval! | findstr /C:"private mounted null" >nul
if !errorlevel! EQU 0 ( set /a adoptable_storage_created=0 & goto :done_check_for_created)
)
)
:done_check_for_created
if !adoptable_storage_created! EQU 1 ( echo SUCCESS & goto :end )
echo FAILED
:end
pause >nul
echo Press any key to continue ...
endlocal & @echo on
exit
jwoegerbauer said:
@Kaguma
Here a small Windows command script that shows all the steps to be performed to transform an external SD-card into internal memory
Important: This is not tested so be aware of potential mistakes
Code:
rem (c) 2020 [email protected] Licensed under GPL v3
@echo OFF & setlocal ENABLEDELAYEDEXPANSION
echo FORMATTING EXTERNAL SD-CARD TO BE USED AS INTERNAL MEMORY ...
set "retval="
set /a device_connected=0
for /f "tokens=*" %%a in ('adb devices') do (
set "retval=%%a"
if NOT [!retva!]==[] (
echo !retval! | findstr /C:":" >nul
if !errorlevel! EQU 0 (set /a device_connected=1 )
)
)
if !device_connected! EQU 0 ( echo NO ANDROID DEVICE CONNECTED & goto :end )
set /a adoptable_sd_memory_is_supported=0
for /f "tokens=*" %%a in ('adb shell "sm has-adoptable"') do (
set "retval=%%a"
if NOT [!retval!]==[] (
echo !retval! | findstr /I /C:"true" >nul
if !errorlevel! EQU 0 ( set /a adoptable_sd_memory_is_supported=1 )
)
)
if !adoptable_sd_memory_is_supported! EQU 0 ( echo FEATURE ADOPTABLE MEMORY NOT SUPPORTED & goto :end )
set "private_sd_card_partition="
for /f "tokens=*" %%a in ('adb shell "sm list-disks adoptable"') do (
set "retval=%%a"
if NOT [!retval!]==[] (
echo !retval! | findstr /C:"disk:" >nul
if !errorlevel! EQU 0 ( set "private_sd_card_partition=!retval!" )
)
)
if [!private_sd_card_partition!]==[] ( echo NO MOUNTABLE SD-CARD PARTITION FOUND & goto :end )
rem
rem Depending on ROM instead of e.g. 179,128 obviously 179_128 must be used
rem If so, uncomment next command line
rem
rem set "private_sd_card_partition=!private_sd_card_partition:,=_!"
echo TRANSFORMING WHOLE EXTERNAL SD-CARD INTO INTERNAL MEMORY ...
echo IT TAKES TIME. BE PATIENT.
adb shell "sm set-force-adoptable true" >nul 2>nul
adb shell "sm partition !private_sd_card_partition! private" >nul 2>nul
adb shell "sm set-force-adoptable false" >nul 2>nul
echo DEVICE NOW GETS RE-BOOTED: DON'T UNPLUG SD-CARD.
adb reboot
adb wait-for-device >nul
:check_for_device_has_booted
for /f "tokens=*" %%a in ('adb shell "getprop sys.boot_completed"') do (
set "retval=%%a"
if NOT [!retval!]==[] (
echo !retval! | findstr /C:"1" >nul
if !errorlevel! EQU 0 ( goto :done_check_for_device_has_booted )
)
)
timeout /t 10 /nobreak >nul
goto :check_for_device_has_booted
:done_check_for_device_has_booted
set /a adoptable_storage_created=1
for /f "tokens=*" %%a in ('adb shell "sm list-volumes all"') do (
set "retval=%%a"
if NOT [!retval!]==[] (
echo !retval! | findstr /C:"private mounted null" >nul
if !errorlevel! EQU 0 ( set /a adoptable_storage_created=0 & goto :done_check_for_created)
)
)
:done_check_for_created
if !adoptable_storage_created! EQU 1 ( echo SUCCESS & goto :end )
echo FAILED
:end
pause >nul
echo Press any key to continue ...
endlocal & @echo on
exit
Click to expand...
Click to collapse
It's really huge, I could maybe test it, thanks
I'll just wait for other answers, but really thanks
Also, do I have to put it after I put the command "adb shell" or where?
And good morning, by the way ^^
(EDIT: What are the eventual consequences / mistakes?)
Kaguma said:
Also, do I have to put it after I put the command "adb shell" or where?
And good morning, by the way ^^
(EDIT: What are the eventual consequences / mistakes?)
Click to expand...
Click to collapse
1. IT'S A WINDOWS COMMAND SCRIPT TO AVOID TYPING
If you want to make use of it, here's the
HOW-TO:
You add /path/to/ADB to Window's PATH environment variable via Windows command prompt ( CMD ) and not via Windows Powershell ( PS )
Code:
set PATH=%PATH%;[color=red]path/to/ADB[/color]
- where /path/to/ADB for example is C:\ADB - and re-boot computer
You create a Windows .BAT file that contains the code listed above - preferredly by copy & paste - and save it under SDTRANSFORMER.BAT
You put the SD-card to be transformed into phone
You connect your running phone via USB cable with computer
You run the .BAT file previously created
As mentioned: Script may contain bugs, if so, then it's on you to fix them - I don't have SD-cards that lie around ..
2. YOU CAN USE ANDROID TERMINAL TO EXECUTE ALL THE SM * COMMANDS , TOO
Notice that this was my last post here, I no longer participate in this thread. Sorry for this.
Thanks for your help, and have a nice day even if you won't reply here
Hi Kaguma,
it doesn't work for Huawei P8 Lite...
stackoverflow.com/questions/60173545/why-i-got-this-error-please-adoptable-storage-not-available-on-device-with-nat
You can try this :
forum.xda-developers.com/p8lite/p8-lite-2017-development/rom-lineageos-17-1-huawei-p8-lite-2017-t4064121

How To Guide Add updated TOYBOX w/ ROOT to Windows Subsystem for Android™️

Preface​
Unfortunately Windows Subsystem for Android (WSA) is missing fully fledged Toybox ( This is a package of over 200 command-line tools, handy for advanced users - it's located in /usr/{bin,sbin} ) - though according to Microsoft WSA is meant to be used by app developers, as development platform, IIRC.
Toybox v0.8.4 ( released 2020-10-24 ) commands currently provided:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
So IMO it's time to install latest fully-fledged version ( at time of this writing it's 0.8.8 released 2022-08-12 ) of Toybox on WSA:
As you can see currently the fully-fledged Toybox command suite contains the SU command ( Toybox as provided with WSA is missing it ) what allows you to root Android, will say give you elevated rights so you get complete access to everything in the operating system, and those permissions allow you to change it all.​
Remarks​USB-Debugging is by default enabled in WSA to implicitly give up your encryption secrets to the connected computer: WSA performs per-file encryption that is software-based.
This suggested updating doesn't replace / remove the pre-installed Toybox version.
Installation into Android's data partition ( recommended )​The roadmap
Connect PC to WSA
Save SELinux context of preinstalled Toybox
Download attached Toybox binary and extract it to any location on PC, e.g. C:\
Download attached SU binary and extract it to any location on PC, e.g. C:\
Next thing to do is to transfer the attached SU binary - assumed it got stored in C:\ - to /sdcard/Download because during the updating process we sometimes need elevated rights
and give executable rights to it
and set its file-ownership-UID 2000 is the default user on WSA
Create a directory named toybox under /data/local/tmp
Transfer the downloaded toybox binary to /sdcard/Download
Disable SElinux what by default in WSA is enabled
Copy the transferred toybox binary to /data/local/tmp what sets its owner to shell:shell
and give executable permission to it. (The default permissions set for other binaries is rwxr-xr-x)
Create symlinks for the all the various tools accessible by toybox binary
Set SELinux context on all files created
Re-enable SELinux because by default in WSA it's enabled
Do some housekeeping ...
and restart WSA
The script - it's a hybrid DOS / Linux coded one
@Echo off & setlocal ENABLEDELAYEDEXPANSION
popd "%CD%"
::
title WSA Toybox Updater
color f0 & mode con: cols=54 lines=40
echo(
echo ####################################
echo # #
echo # WSA Toybox Updater #
echo # #
echo # Updates existing Toybox to #
echo # version 0.8.8 what comes with #
echo # SU-function embeddedd #
echo # #
echo # (c) 2022 [email protected] #
echo # License: BSD 2-Clause #
echo # #
echo ####################################
echo(
echo Press 1 to Continue, 0 to Abort
choice /C 10 /M "Please select"
if !errorlevel! NEQ 1 ( goto :done )
cls
::
set "adb="
set "subin="
set "tbbin="
set "adb_org=adb_r33.0.3.exe"
set "tbbin_org=toybox-x86_64"
set "subin_org=su-x86_64"
set "wsa_svc=WsaService.exe"
set "address=127.0.0.1"
::
:: Sanity checks
echo(
echo Verifying availability of required files ..
for /F "tokens=*" %%t in ('fsutil fsinfo drives') do ( set "drives=%%t" )
:: 1st check folder we are running this bat from, 2nd search all drives
set "drive=%CD:~0,2%"
for /F "tokens=*" %%t in ('where /R !drive! !adb_org! 2^>nul') do ( set "adb=%%t" )
if defined adb ( goto :done_query_adb_org )
for /F "tokens=2* delims= " %%a in ("!drives!") do (
set "drive2=%%a"
for /F "tokens=*" %%t in ('where /R !drive2! !adb_org! 2^>nul') do ( set "adb=%%t" )
if defined adb ( goto :done_query_adb_org )
)
echo FATAL: !adb_org! not found on PC & goto :failed
:done_query_adb_org
for /F "tokens=*" %%t in ('where /R !drive! !subin_org! 2^>nul') do ( set "subin=%%t" )
if defined subin ( goto :done_query_subin_org )
for /F "tokens=2* delims= " %%a in ("!drives!") do (
set "drive2=%%a"
for /F "tokens=*" %%t in ('where /R !drive2! !subin_org! 2^>nul') do ( set "subin=%%t" )
if defined subin ( goto :done_query_subin_org )
)
echo FATAL: !subin_org! not found on PC & goto :failed
:done_query_subin_org
for /F "tokens=*" %%t in ('where /R !drive! !tbbin_org! 2^>nul') do ( set "tbbin=%%t" )
if defined tbbin ( goto :done_query_tbbin_org )
for /F "tokens=2* delims= " %%a in ("!drives!") do (
set "drive2=%%a"
for /F "tokens=*" %%t in ('where /R !drive2! !tbbin_org! 2^>nul') do ( set "subin=%%t" )
if defined subin ( goto :done_query_subin_org )
)
echo FATAL: !tbbin_org! not found on PC & goto :failed
:done_query_tbbin_org
echo OK
echo(
echo Checking if WSA emulator is running ...
for /F "tokens=1 delims= " %%t in ('tasklist /FI "IMAGENAME eq !wsa_svc!" 2^>nul ^| findstr /I /C:"!wsa_svc!"') do (
set "proc=%%t"
if NOT "!proc!"==[] ( goto :done_wsa_check )
)
echo FATAL: WSA is not running & goto :failed
:done_wsa_check
echo OK
tasklist /FI "IMAGENAME eq adb*" | findstr /I /C:"adb" >nul && goto :adb_running || goto :adb_not_running
:adb_running
!adb! disconnect >nul 2>&1
:: Force a fresh start of ADB
taskkill /FI "IMAGENAME eq adb*" /IM >nul 2>&1
:adb_not_running
echo(
echo Connecting Windows to WSA emulator ...
:: Ports are odd-numbered in the range 5555 to 5585,
:: the default port is 5555
for /L %%a in (5555,2,5585) do (
set "tcpport=%%a"
!adb! connect !address!:!tcpport! >nul 2>&1
:: Verify WSA emulator is connected
for /F "tokens=*" %%t in ('!adb! get-state 2^>nul') do (
set "state=%%t"
echo !state! | findstr /C:"device" >nul
if !errorlevel! EQU 0 ( goto :done_wsa_connection )
)
)
echo FATAL: WSA emulator got not connected & goto :failed
:done_wsa_connection
echo OK
::
::
::
set "subin_fn=su"
set "tbbin_fn=toybox"
set "dldir=/sdcard/Download"
set "sucmd=!dldir!/!subin_fn!"
set "tmpdir=/data/local/tmp"
set "tbdir=!tmpdir!/!tbbin_fn!"
::
::
set "sucmd=!dldir!/!subin_fn!"
set "tbbin=!dldir!/!tbbin_fn!"
:: Check if job already was done
echo(
echo Validating Toybox update already done ...
set /A fc=0
!adb! pull !sucmd! %TEMP%\!subin_fn! >nul 2>&1
if !errorlevel! EQU 0 ( set /A fc+=1 )
!adb! pull !tbbin! %TEMP%\!tbbin_fn! >nul 2>&1
if !errorlevel! EQU 0 ( set /A fc+=1 )
if exist "%TEMP%\!subin_fn!" ( del /F /Q "%TEMP%\!subin_fn!" )
if exist "%TEMP%\!tbbin_fn!" ( del /F /Q "%TEMP%\!tbbin_fn!" )
if !fc! EQU 2 ( echo OK & goto :done_files_transferred )
echo OK
echo(
echo Transferring files ...
:: Transfer SU binary to /sdcard/Download
:: because during the updating process we sometimes need elevated rights
!adb! push !subin_org! !dldir!/
if !errorlevel! NEQ 0 (
echo Failed: Transferring SU failed
goto :failed
)
:: Transfer the downloaded toybox binary to /sdcard/Download
!adb! push !tbbin_org! !dldir!/ >nul 2>&1
if !errorlevel! NEQ 0 (
echo Failed: Transferring Toybox failed
goto :failed
)
:done_files_transferred
echo OK
::
echo(
echo Updating Toybox ...
::
:: start Android shell on the WSA emulator
::
!adb! shell
set -e
#
#
DL_DIR=/sdcard/Download;
TB_DIR=/data/local/tmp/toybox;
TB_BIN=/data/local/tmp/toybox/toybox;
SU_BIN="$DL_DIR"/su;
SU_BIN_ORG=su-x86_64;
TB_BIN_ORG=toybox-x86_64;
cat < SCRIPT > "$DL_DIR"/cat.sh & chmod +x "$DL_DIR"/cat.sh & source < "$DL_DIR"/cat.sh; \
'# Save SELinux context of pre-installed Toybox' \
TOYBOX="$(which 'toybox')"; \
EXPR=$(ls -lZ "$TOYBOX"); \
TB_SECURITY_CONTEXT=$(cut -d " " -f 4 "$EXPR"); \
'# give SU binary executable rights' \
'# Get UID GID from pre-installed toybox' \
EXPR="$(ls -ld "$TOYBOX")"; \
TB_UID=$(cut -d " " -f 3 "$EXPR"); \
TB_GID=$(cut -d " " -f 4 "$EXPR"); \
'# Set these UID GID on SU too' \
chown -f "$TB_UID":"$TB_GID" "$SU_BIN"; \
'# Create a directory named toybox under /data/local/tmp' \
if [ ! -d "$TB_DIR" ]; then ( \
$SU_BIN -c 'mkdir -p "$TB_DIR" 2>/dev/null; touch "$TB_DIR" 2>/dev/null'; \
fi; \
'# rename SU and Toybox binaries provided if not already exist' \
if [[ (! -f "$SU_BIN" || ! -f "$TB_BIN") ]]; then { \
mv -T "$DL_DIR/$SU_BIN_ORG" "$SU_BIN" 2>/dev/null; \
mv -T "$DL_DIR/$TB_BIN_ORG" "$TB_BIN" 2>/dev/null; \
} \
fi; \
'# Temporarily disable SElinux what by default in WSA is enabled' \
$SU_BIN 0 setenforce 0; \
'# Copy the transferred toybox binary to /data/local/tmp/toybox what sets its owner to shell:shell' \
cp -Tp "$TB_BIN_ORG" "$TB_DIR/$TB_BIN" >/dev/null; \
'# and give executable permission to it' \
chmod -f +x "$TB_DIR"; \
'# Create symlinks for the various Linux applets provided by toybox binary' \
for i in $($TB_DIR/$TB_BIN --long); do ln -s $TB_DIR/$TB_BIN $i; done: \
'# Set SELinux context on all files created'
$SU_BIN -c 'chcon -R "$TB_SECURITY_CONTEXT toybox" "$TB_DIR"; \
'# Re-enable SELinux because by default in WSA it's enabled' \
$SU_BIN 0 setenforce 1; \
'# Do some housekeeping ...' \
rm -f "$SU_BIN","$TB_BIN" 2>/dev/null; \
SCRIPT
#
## exit the Android shell
exit
::
::
echo OK
:: and restart
echo(
echo Restarting WSA ...
!adb! reboot
echo OK
:failed
timeout /t 10 /nobreak >nul
::
:done
echo(
echo Job done. Exiting ...
pause
pushd
taskkill /FI "IMAGENAME eq adb*" /IM >nul 2>&1
endlocal & DISABLEDELAYEDEXPANSION
exit
Screenshot
Done​Enjoy your Toybox and its applets are ready to be executed.
Validation​
( using ADB code stored in a Windows .BAT-file )
Code:
@echo off & setlocal ENABLEDELAYEDEXPANSION
pushd "%CD%"
::
::
set "adb_exe=adb_r33.0.3.exe" & set "adb="
set "ip4_address=" & set "port=58526"
set "wsa_svc=WsaService.exe"
::
::
title WSA-TOYBOX-UPDATE-VALIDATOR
color f0 & mode con: cols=50 lines=40
echo(
echo ####################################
echo # #
echo # WSA Toybox Update Validator #
echo # #
echo # Verifies Toybox got updated to #
echo # version 0.8.8 what comes with #
echo # SU-function embeddedd #
echo # #
echo # (c) 2022 [email protected] #
echo # License: BSD 2-Clause #
echo # #
echo ####################################
echo(
echo Verifying presence of ADB executable ...
:: check folder we are running this bat from
set "drive=%CD:~0,2%"
for /F "tokens=*" %%t in ('where /R !drive! !adb_exe! 2^>nul') do ( set "adb=%%t" )
if defined adb ( goto :done_query_adb )
echo FATAL: !adb_exe! not found on PC & goto :failed
:done_query_adb
echo OK & echo(
echo Checking if WSA emulator is already up ...
for /F "tokens=1 delims= " %%t in ('tasklist /FI "IMAGENAME eq !wsa_svc!" 2^>nul ^| findstr /I /C:"!wsa_svc!"') do (
set "proc=%%t"
if NOT "!proc!"==[] ( goto :done_wsa_check )
)
echo FATAL: WSA is not running & goto :failed
:done_wsa_check
echo OK & echo(
:: Force a fresh start of ADBis
tasklist /FI "IMAGENAME eq adb*" | findstr /I /C:"adb" >nul 2>nul && goto :adb_is_running || goto :adb_isnot_running
:adb_is_running
:: disconnect all
!adb! disconnect >nul 2>&1
taskkill /FI "IMAGENAME eq adb*" /IM >nul 2>&1
:adb_isnot_running
::
:: get our IP4 address
echo Obtaining local IP4 address ...
rem for /F “tokens=1,2 delims=:" %%a in ('ipconfig ^| findstr /I /C:"ipv4" ^>nul') do (
rem if !errorlevel! EQU 0 ( set "ip4_address=%%b" )
rem )
if defined ip4_address ( goto :done_query_ip4_address )
:: workaround
set "ip4_address=127.0.0.1"
:done_query_ip4_address
echo OK ^[ !ip4_address!^] & echo(
echo Connecting to emulator ...
:: start using default port
!adb! connect !ip4_address!:!port! >nul
for /F "tokens=*" %%t in ('!adb! get-state ^>nul 2^>^&1 ^| findstr /C:"device" ^>nul 2^>nul') do (
set "retval=%%t"
if "!retval!"==[] ( echo Internal error occured & timeout /t 5 /nobreak >nul & goto :oops )
)
echo OK & echo(
echo Checking for SU applet is reachable ...
!adb! shell "PATH=/data/local/tmp/toybox:$PATH; su 2>/dev/null; STATUS=$?;[ $STATUS -eq 0 ] && echo "OK" || echo "Failed"; sleep 10s;"
:oops
taskkill /FI "IMAGENAME eq adb*" /IM >nul 2>&1
:failed
echo(
pause
popd
endlocal DISABLEDELAYEDEXPANSION
exit
Screenshot:
Download​
This package got attached for your convenience
Last Note​Toybox applets are for Terminal and shell scripts - you may use ScriptRunner2 for the latter.
BTW:
Before running a script edit your default shell's configuration file via adding in an DOS coded script saved to a .BAT-file
Code:
adb shell "PATH=/data/local/tmp/toybox:$PATH"
at script's begin what would cause the shell to look into /data/local/tmp/toybox first and execute the binary, if available.
Toybox command help​is here:
Toybox 0.8.9 command help
[reserved]
Can you provide an installer script? It would make it easer for all. Thanks in advance.
Sure. But needs some time. Stay tuned.
jwoegerbauer said:
if !su_found! EQU 1 ( echo SU binary found )
else ( echo SU binary not found )
Click to expand...
Click to collapse
"Else" needs to be on the same line as the "if" in order to be read by interpreter.
Or the ")" + "else" needs to drop to the line below it.
Should be:
if !su_found! EQU 1 ( echo SU binary found ) else ( echo SU binary not found )
OR
if !su_found! EQU 1 ( echo SU binary found
) else ( echo SU binary not found )
EDIT: Also, "@ECHO on" turns on verbose command output, does no good to place at the very end (no harm either)
Thanks for that error notice: implicitely corrected it by a complete revamp of the script.
can you provide a shell script command please

Categories

Resources