的環境,在這裏Is it possible to set an environment variable to the output of a command in cmd.exe說我一直使用的窗口oneliner設置命令輸出變量
mycommand.exe>%TEMP%\out.txt
set /P FOO=<%TEMP%\out.txt
但是,這是醜陋的,因爲它創建了一個文件。
的for
方法是更好,但複雜
我想要的東西簡單一拉UNIX,如:
mycommand.exe|set /P FOO=
沒有錯誤,但我FOO
運行後未設置。
爲什麼這不起作用?
請參閱[本文]中的說明(http://stackoverflow.com/questions/8192318/why-does-delayed-expansion-fail-when-inside-a-piped-block-of-code/) – Aacini