我正在制作以下批处理脚本
set FileVersion = powershell (Get-Command C:\Tool.exe).FileVersionInfo.ProductVersion
echo %FileVersion%
我想检索文件C:\ Tool.exe的属性“产品版本”。为此,我使用了一个powershell命令,我想将该值保存到一个名为“文件版本”的变量中,然后再打印出来,但是它不起作用! 你能帮我吗?
答案 0 :(得分:1)
对于某些尚未理解的逻辑,必须使用FOR loop
。
FOR /F "delims=" %%A IN ('powershell (Get-Command C:\Tool.exe).FileVersionInfo.ProductVersion') DO (SET "FileVersion=%%~A")