Increment the version in .rc file using batch script

September 22, 2014 at 03:07:35
Specs: windows
I have a .rc file like this:
///////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "Sample Application\0"
VALUE "CompanyName", "Microsoft Corp.\0"
VALUE "FileDescription", "MyProject MFC Application\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "MyProject\0"
VALUE "LegalCopyright", "Copyright (C) 1999\0"
VALUE "OriginalFilename", "MyProject.EXE\0"
VALUE "ProductName", "MyProject Application\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

each time i will trigger the build the file version and product version needs to increment automatically. pls help me


See More: Increment the version in .rc file using batch script

Report •


#1
Report •

#2
September 22, 2014 at 09:53:01
Thanks for your reply but I need batch script for increment instead of macro.
Thanks in advance

Report •

#3
September 22, 2014 at 10:07:15
VBScript is the native Windows 9x/NT4+scripting language.
It has better data control, and better OS compatibility.
Compatibility both in the sense that its behavior is more consistent between OS versions, and in its ability to communicate with different layers of the OS. (Like the shell.)
It is one of the pillars of Window's domain strategy.
It has better error handling.

Unless you're in a specialized environment where you do not have the COM foundation for Windows' script engine, but do have cmd.exe, you have no reason not to use VBScript.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
September 22, 2014 at 23:31:49
Do all these lines need to be changed, or only the F* P*, leaving the V* alone?

FILEVERSION 1,0,0,1
VALUE "FileVersion", "1, 0, 0, 1\0"

PRODUCTVERSION 1,0,0,1
VALUE "ProductVersion", "1, 0, 0, 1\0"

Does 1,0,0,1 become 1,0,0,2? or what
======================================
R2 is right, of course, vbs is the schmitz for this stuff.
But I gave up long ago wondering why someone wants to do whatever.

=====================
M2 Golden-Triangle


Report •

#5
September 22, 2014 at 23:36:40
need to change all the line

FILEVERSION 1,0,0,1
VALUE "FileVersion", "1, 0, 0, 1"
PRODUCTVERSION 1,0,0,1
VALUE "ProductVersion", "1, 0, 0, 1"
as

FILEVERSION 1,0,0,2
VALUE "FileVersion", "1, 0, 0, 2"
PRODUCTVERSION 1,0,0,2
VALUE "ProductVersion", "1, 0, 0, 2"

thanks in advance.


Report •

#6
September 23, 2014 at 03:05:30
Your original post had this:
VALUE "ProductVersion", "1, 0, 0, 1\0"

So, which is it?

=====================
M2 Golden-Triangle


Report •

#7
September 23, 2014 at 03:22:26
This is the one which i need the solution

FILEVERSION 1,0,0,1
VALUE "FileVersion", "1, 0, 0, 1"
PRODUCTVERSION 1,0,0,1
VALUE "ProductVersion", "1, 0, 0, 1"

please ignore the one which you mentioned

message edited by dhinesh


Report •

#8
September 26, 2014 at 23:57:18
:: I knew this would get messy.
:: 13:51 27 September 2014
::
::====== script starts here ===============
:: Increments version style 1,0,0,1 OR "1, 0, 0, 1"
:: verinc.bat 2014-09-23 13:10:34.49
@echo off > NEWFILE & setLocal enableDELAYedeXpansioN


:main
for /f "tokens=* delims= " %%a in (myfile) do (
set S=%%a & call :sub1 !S!
) >> NEWFILE
goto :eof

:sub1
for /f "tokens=1-6 delims= " %%i in ('echo %*') do (
if %%i equ VALUE if %%j equ "FileVersion" (
set P=%%i %%j
call :inc1 %%k %%l %%m %%n
set S=!P! !V!
)

if %%i equ VALUE if %%j equ "ProductVersion" (
set P=%%i %%j
call :inc1 %%k %%l %%m %%n
set S=!P! !V!
)

if %%i equ FILEVERSION (
set P=%%i
call :inc2 %%j %%k %%l %%m
set S=!P! !V!
)
if %%i equ PRODUCTVERSION (
set P=%%i
call :inc2 %%j %%k %%l %%m
set S=!P! !V!
)
echo.!S!
)
goto :eof

:inc1 ==================================== handles "1, 0, 0, 1"
for /f "tokens=1-9 delims= " %%i in ('echo %*') do (
set/a N=%%l+1
set V=%%i,%%j,%%k,!N!
set V=!V:,,=,!
set V=!V!"
)
goto :eof

:inc2 ===================================== handles 1,0,0,1
for /f "tokens=1-9 delims= " %%i in ('echo %*') do (
set/a N=%%l+1
set V=%%i,%%j,%%k,!N!
)
goto :eof

::====== script ends here =================

=====================
M2 Golden-Triangle


Report •


Ask Question