batch-file - 管道之后 "set -P"为什么不起作用?

标签 batch-file cmd set pipe

C:\>type c:\output.txt
abcd
C:\>type c:\output.txt | set /p V1=

C:\>set
... A bunch of junk, NOT seeing "V1"

发生了什么?根据我所见的SET的所有文档,应该从上面为%V1%分配一个值“abcd”,不是吗?

如果有问题,我使用的是Windows XP Pro,SP3。

最佳答案

管道似乎创建了一个新的CMD实例,以执行接收管道数据的下一个命令。因此,当管道结束时,该CMD实例将退出并且变量将丢失。

关于batch-file - 管道之后 "set -P"为什么不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3446972/

相关文章:

javascript - Webstorm File Watchers 永远重复调用批处理文件

windows - 删除应用程序时 UninstallString 中的多个命令

lua - 如何运行 .lua 脚本?

windows - Windows XP 真的有负错误代码吗?

python - 设置交集,将一定范围内的值视为相交

windows - 任务计划程序 : Run a Java program after a Python script finishes

Windows .bat 文件,%~$PATH :1 quotes issue

batch-file - 我如何将 11 添加到 %%i?

组合两个 Set 时出现 java.lang.UnsupportedOperationException

python - 集合和 View 之间的区别