A windows batch to read Android TV pkg with install time

发布时间:2023年12月18日
@echo off
setlocal enabledelayedexpansion

REM Create a temporary file
echo %cd% 
set tempfile=.\adb_packages.txt
set tempOutput=.\output.txt

REM Get the list of packages
adb shell pm list packages -f > %tempfile%

REM Process each package
for /f "tokens=*" %%a in (%tempfile%) do (
    REM Extract the package name
    set pkg=%%a
    for /f "tokens=2 delims==" %%b in ("!pkg!") do (
        set pkg=%%b
		echo !pkg!
		REM echo %%b
		REM echo %cd% 
		adb shell dumpsys package  %%b > %tempOutput%

		:: Process each line in the file
		for /f "delims=" %%a in (%tempOutput%) do (
			:: Check if the line contains str1 or str2
			echo "%%a" | findstr /C:"firstInstallTime" 1>nul
			if !errorlevel! equ 0 (
				echo !pkg! "%%a"
			)
			echo "%%a" | findstr /C:"lastUpdateTime" 1>nul
			if !errorlevel! equ 0 (
				echo !pkg! "%%a"
			)
		)
 
		del %tempOutput%
    )
)

REM Delete the temporary file
del %tempfile%

endlocal


?

文章来源:https://blog.csdn.net/raidtest/article/details/135054496
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。