powershell - 自动化 adb push 返回空变量
问题描述
我想制作一个批处理文件(或者 PowerShell,如果你更喜欢它,你可以选择。我的代码是一个批处理文件),以自动将文件传输到 Android 设备
因此,用户将被询问原始文件的位置和名称然后,用户被询问目的地的位置。然后,运行 adb push 命令
我的代码是:
set /p filename="What is the location and name of the file you want to transfer? > "
set /p location="What is the location you want to set it to? > "
set fullmsg=adb push '%filename%' '%loaction%'
echo %fullmsg%
#just echoing out, to make shure it's correct
pause
现在发生的是,它输出:
adb push 'file.txt' ''
所以,这个位置是空的。另外,如果文件名有撇号 (') 或类似的东西怎么办:那是 right.txt
当然,它需要用引号引起来,但如果你有这样的位置:\\mysharedfolder\text files\ #注意反斜杠以及单词 text 和 files 之间的空格
希望这个解释足够好,因为我不知道如何解释它。
提前致谢
解决方案
在 PowerShell 中:
$file = Read-Host 'What is the location and name of the file you want to transfer?'
$location = Read-Host 'What is the location you want to set it to?'
# Showing command about to be run
Write-Host "adb push $file $location"
# pausing before running command
pause
adb push $file $location
推荐阅读
- tensorflow - 何时在时间序列中使用生成器 TensorFlow
- javascript - 使用 Javascript 的电子邮件验证不适用于 HTML
- asp.net-core - 令牌无效 - 观众“空”无效
- html - 如何使文本适合容器元素的整个高度
- reactjs - 反应单选按钮 - 部分工作 - 正确获取数据 - 但未呈现为选中状态
- python - 获取:'IndexError:索引 1 超出轴 0 的范围,大小为 0',但不知道为什么
- python - NetBox 安装期间出错,无法使用 manage.py 创建超级用户
- python - Pycairo:如何正确实例化 cairo.XlibSurface()?
- python - 如何更改selfbot的存在
- java - 在spring可以解析微服务实例的IP地址[jhipster]