Powershell对.bat感到困惑

玩家:

我试图通过批处理运行以下命令,但我得到的只是命令的回声。

PowerShell -command "&{Get-Content C:\temp\serversetup2\num.txt | Select-Object -Index 0 > num2.txt}"

命令在PowerShell本身上运行良好,但不会批量启动

组合:

我不确定是否理解您为什么要使用来完成此任务:

Set /P "$_=" 0< "C:\temp\serversetup2\num.txt" & ("%__AppDir__%cmd.exe" /D/Q/V/C Echo !$_!) 1> "num2.txt"

但要这样做,请尝试如下操作:

"%__AppDir__%WindowsPowerShell\v1.0\powershell.exe" -NoProfile "Get-Content 'C:\temp\serversetup2\num.txt' | Select-Object -Index 0" 1> "num2.txt"

或者可能是这样:

"%__AppDir__%WindowsPowerShell\v1.0\powershell.exe" -NoProfile "Get-Content 'C:\temp\serversetup2\num.txt' | Select-Object -Index 0 | Set-Content 'num2.txt'"

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章