1@rem Copyright (c) 2024 Huawei Device Co., Ltd. 2@rem Licensed under the Apache License, Version 2.0 (the "License"); 3@rem you may not use this file except in compliance with the License. 4@rem You may obtain a copy of the License at 5@rem 6@rem http://www.apache.org/licenses/LICENSE-2.0 7@rem 8@rem Unless required by applicable law or agreed to in writing, software 9@rem distributed under the License is distributed on an "AS IS" BASIS, 10@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11@rem See the License for the specific language governing permissions and 12@rem limitations under the License. 13 14@echo off 15setlocal enabledelayedexpansion 16 17@rem ########################################################################## 18@rem 19@rem Verifier-Pull-Haps startup script for Windows 20@rem 21@rem ########################################################################## 22 23@rem Initialize variables 24set "device=" 25set "device_count=0" 26 27@rem Check if a device is connected 28echo Checking for connected devices... 29for /f "delims=" %%i in ('hdc list targets') do ( 30 if not "%%i"=="" ( 31 set "device=%%i" 32 set /a device_count+=1 33 ) 34) 35 36@rem Verify if device information is valid 37if "%device%"=="[Empty]" ( 38 echo No devices connected. Please connect a device first. 39 pause 40 exit /b 41) 42 43@rem Debugging output 44echo Device count: %device_count% 45 46echo Device connected: %device% 47 48@rem Create target directory if it does not exist 49set target_dir=D:\system_haps 50if not exist "%target_dir%" ( 51 mkdir "%target_dir%" 52 echo Created directory %target_dir% 53) 54 55@rem Retrieve list of .hap files from the device 56echo Retrieving list of .hap files from device... 57hdc shell find /system/app -name *.hap > hap_files.txt 58 59@rem Check if hap_files.txt is empty 60for /f "delims=" %%f in (hap_files.txt) do ( 61 if not "%%f"=="" ( 62 set "hapFile=%%f" 63 echo Pulling file: !hapFile! 64 hdc file recv "!hapFile!" "%target_dir%" 65 ) 66) 67 68@rem Clean up temporary files 69del hap_files.txt 70 71echo Done. 72pause 73