0

I'm making following batch script

set FileVersion = powershell (Get-Command C:\Tool.exe).FileVersionInfo.ProductVersion

echo %FileVersion%

I'd like retrieve attribute 'Product Version' of file C:\Tool.exe. To do that I use a powershell command and I want save that value to a variable called 'File Version' and later print out it, but it doesnt works! Can you help me?

  • Just be aware that you may not get [the string you were expecting](https://imgur.com/u9PcCgE). – Compo Jun 26 '20 at 16:00

1 Answers1

1

For some yet to be understood logic, a FOR loop must be used.

FOR /F "delims=" %%A IN ('powershell (Get-Command C:\Tool.exe).FileVersionInfo.ProductVersion') DO (SET "FileVersion=%%~A")
lit
  • 14,456
  • 10
  • 65
  • 119