# commonTool **Repository Path**: Cooper0/common-tool ## Basic Information - **Project Name**: commonTool - **Description**: 常用脚本工具集合,用于日常使用 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-07-10 - **Last Updated**: 2024-03-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 通用脚本工具。 脚本可能涉及多种脚本语言,需要特别安装环境的会单独说明。 # 通用环境配置 - `git clone` 仓库到本地 - 将仓库所在文件夹添加到系统环境变量,重启系统加载环境变量 - 即可直接执行对应的脚本 # `hdc_push_file_to_device.ps1` 使用执行目录下的`push_list.txt`作为配置文件push文件到设备中 `push_list.txt`的书写要求如下: - 每行书写一个push规则 - 每个规则由两部分组成,本地文件路径 对端文件路径,中间由空格做分割 - 本地文件路径可以是相对路径也可以是绝对路径, 脚本会检测文件存在与否 - 对端设备文件路径是绝对路径,脚本会检测文件是否存在,存在文件才会push - 文件路径既可以用`/`也可以用`\`做文件路径,脚本会将本地文件路径中的`/`转换为`\`, 对端则相反 - **不能是文件夹**,push之后会对两个文件进行MD5值的比较,所以只能是文件,文件夹暂不支持 `push_list.txt`示例: ```push_list.txt .\test_file /system/lib/test_file ``` # `hdc_push_file_to_device.bat` 使用bat实现功能同 `hdc_push_file_to_device.ps1`, 但是没有进行md5的校验。 # FAQ ## 执行`ps1`脚本报错 ``` + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand ``` ![](./image/powershell_policy_error.PNG) 这是由于系统默认策略限制了执行`ps1`脚本导致的。将策略改为`RemoteSigned` 或者 `Unrestricted` 即可。 具体修改步骤: - 用管理员权限打开`powershell` - 使用 `Get-ExecutionPolicy` 可以查看当前策略 - 使用 `Set-ExecutionPolicy` 设置对应的策略。![](./image/powershell_policy_1.PNG) - 设置成功后即可正常运行对应脚本