How can i extract the version number of a file present within a directory using command line in my batch script?
Asked
Active
Viewed 337 times
1
-
possible duplicate of [How do I retrieve the version of a file from a batch file on Windows Vista?](http://stackoverflow.com/questions/1706892/how-do-i-retrieve-the-version-of-a-file-from-a-batch-file-on-windows-vista) – shruti1810 Jun 23 '15 at 05:59
-
Sorry but I am looking from the support perspective so that the patch that we create for our software works on any windows machine. I do not want it to be dependent on any other external utility which would not server the purpose For ex: powershell doesnt exist in all the machines and customers/clients may not have it on their machines. – irish Jun 23 '15 at 06:09
-
I have used sygcheck to fetch the information and then sfk to get the binary version of the file which comes out this way Binary Version: 9.1.0.37019, i would like just "9.1.0.37019" and nothing before that in my temp file which means anything that comes before it is to be removed from within the file. How could i possibly do that? – irish Jun 23 '15 at 06:19
2 Answers
0
You can try this batch file wrapped with powershell :
@echo off
echo.
set /p PathFile="Enter the absolute path to your application to retrieve its version > "
echo.
SET ScriptDirectory=%~dp0
SET ScriptPath=%ScriptDirectory%FileVersion.ps1
echo (Get-Item '%PathFile%').VersionInfo.FileVersion > %ScriptPath%
cmd /k PowerShell -NoProfile -ExecutionPolicy Unrestricted -File ""%ScriptPath%""

Hackoo
- 18,337
- 3
- 40
- 70
-
Thanks Hackoo, I believe sigcheck has done the job for me. and i extract a certain information generated out of sigcheck. Now i need to do the following: 1. I have the detabbed output in a tmp file, i want to remove the first 17 characters from the tmp file and put the result in another temp2 file 2. Then i want to store the value in temp2 in a variable so that i can use the variable for IF conditions. Could you please advise? – irish Jun 23 '15 at 23:48
-
Ok i have managed to do this by sfk replace and i have a value know which i put into a variable by using set /p string =< test.tmp. Now in the next step i want to compare %string% value for ex: if %string% EQU 9.1.0 GOTO Install but this doesnt seem to be working.... how do i use If statement here in cmd? – irish Jun 24 '15 at 00:30
0
used sigcheck utility to extract file version info.
I downloaded sigcheck.exe which is about 290KB and then fetched the file version info using this command:
SIGCHECK -a C:\Program Files(x86)\Software\bin\Software.exe

irish
- 197
- 1
- 2
- 18