2016-09-06 15:31:41 -04:00
|
|
|
:: Usage:
|
2018-10-13 07:19:22 -04:00
|
|
|
:: call get-rs-version.bat Executable Variable
|
|
|
|
::
|
|
|
|
:: Variable.Major
|
|
|
|
:: Variable.Minor
|
|
|
|
:: Variable.Mini
|
|
|
|
:: Variable.Extra
|
2015-08-04 13:02:13 -04:00
|
|
|
|
2016-09-06 15:31:41 -04:00
|
|
|
setlocal
|
2015-08-04 13:02:13 -04:00
|
|
|
|
2018-10-13 07:19:22 -04:00
|
|
|
set Executable=%~1
|
2015-08-04 13:02:13 -04:00
|
|
|
set Variable=%~2
|
|
|
|
if "%Variable%"=="" (
|
|
|
|
echo.
|
2016-09-06 15:31:41 -04:00
|
|
|
echo Parameter error.
|
|
|
|
exit /B 1
|
2015-08-04 13:02:13 -04:00
|
|
|
)
|
|
|
|
|
2018-10-13 07:19:22 -04:00
|
|
|
if not exist "%Executable%" (
|
2015-08-04 13:02:13 -04:00
|
|
|
echo.
|
2018-10-13 07:19:22 -04:00
|
|
|
echo File %Executable% doesn't exist.
|
2015-08-04 13:02:13 -04:00
|
|
|
exit /B1
|
|
|
|
)
|
|
|
|
|
2018-10-13 07:19:22 -04:00
|
|
|
set VersionMajor=
|
|
|
|
set VersionMinor=
|
|
|
|
set VersionMini=
|
|
|
|
set VersionExtra=
|
|
|
|
|
2020-07-30 18:51:18 -04:00
|
|
|
for /F "USEBACKQ tokens=1,2,3,* delims=.-" %%A in (`powershell -NoLogo -NoProfile -Command ^(Get-Item "%Executable%"^).VersionInfo.FileVersion`) do (
|
2018-10-13 07:19:22 -04:00
|
|
|
set VersionMajor=%%A
|
|
|
|
set VersionMinor=%%B
|
|
|
|
set VersionMini=%%C
|
|
|
|
set VersionExtra=%%D
|
2015-08-04 13:02:13 -04:00
|
|
|
)
|
|
|
|
|
2018-10-13 07:19:22 -04:00
|
|
|
endlocal & set %Variable%.Major=%VersionMajor%& set %Variable%.Minor=%VersionMinor%& set %Variable%.Mini=%VersionMini%& set %Variable%.Extra=%VersionExtra%&
|
2015-08-04 13:02:13 -04:00
|
|
|
exit /B 0
|