WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Compiler
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Determine Version of Compiler Used to Compile an EXE

 Keywords: Determine Version Compiler Compile EXE ToolsetBuildInfo File Property Compiletime

Question:

I need to get the version of WinBatch+Compiler that was used to compile an EXE. How can I accomplish this from a WinBatch script?

Answer:

When the WinBatch+Compiler builds an EXE it stores the version infomation about the compiler that was used in the File Versions ToolsetBuildInfo property. You can use the following code to read this information from a compiled EXE:
filename = DirScript():'a.exe'
ret = FileVerInfo(filename, '', 'ToolsetBuildInfo' )
Pause( 'Version used to Compile this exe - ToolsetBuildInfo', ret )
Exit
You can also retrieve the compile date and time using:
filename = DirScript():'a.exe'
ret = FileVerInfo(filename, '', 'CompileTime' )
Pause( 'CompileTime', ret )
Exit


These are (undocumented) custom strings added by the WinBatch+Compiler. These apply to a Compiled WinBatch Exe.

Compiletime   
ToolsetBuildInfo    
ToolsetCopyright 
Here is a more complete code sample:
WbtPgm = IntControl(1004,0,0,0,0)
If RtStatus() == 1 ;Compiled Exe
   Lang = "";'0asdasf'
   FileVersion = FileVerInfo(WbtPgm, Lang, "FileVersion" )
   ProductVersion = FileVerInfo(WbtPgm, Lang, "ProductVersion" )
   Comments = FileVerInfo(WbtPgm, Lang, "Comments" )
   LegalCopyright = FileVerInfo(WbtPgm, Lang, "LegalCopyright" )
   CompanyName = FileVerInfo(WbtPgm, Lang, "CompanyName" )
   LegalTrademarks = FileVerInfo(WbtPgm, Lang, "LegalTrademarks" )
   FileDescription = FileVerInfo(WbtPgm, Lang, "FileDescription" )
   OriginalFilename = FileVerInfo(WbtPgm, Lang, "OriginalFilename" )
   ProductName = FileVerInfo(WbtPgm, Lang, "ProductName" )
   InternalName = FileVerInfo(WbtPgm, Lang, "InternalName" )
   Msg = "FileVersion: ":FileVersion:@LF:"ProductVersion: ":ProductVersion:@LF:"Comments: ":Comments:@LF:"LegalCopyright: ":LegalCopyright:@LF:"CompanyName: ":CompanyName:@LF:"LegalTrademarks: ":LegalTrademarks:@LF:"FileDescription: ":FileDescription:@LF:"OriginalFilename: ":OriginalFilename:@LF:"ProductName: ":ProductName:@LF:"InternalName: ":InternalName
   Pause( "Resource Strings", Msg )

   nFileVersion = FileVerInfo(WbtPgm, Lang, "#FileVersion" )
   nProductVersion = FileVerInfo(WbtPgm, Lang, "#ProductVersion" )
   nFileFlagsMask = FileVerInfo(WbtPgm, Lang, "#FileFlagsMask" )
   nFileFlags = FileVerInfo(WbtPgm, Lang, "#FileFlags" )
   nFileOS = FileVerInfo(WbtPgm, Lang, "#FileOS" )
   nFileType = FileVerInfo(WbtPgm, Lang, "#FileType" )
   nFileSubtype = FileVerInfo(WbtPgm, Lang, "#FileSubtype" )
   Msg = "#FileVersion: ":nFileVersion:@LF:"#ProductVersion: ":nProductVersion:@LF:"#FileFlagsMask: ":nFileFlagsMask:@LF:"#FileFlags: ":nFileFlags:@LF:"#FileOS: ":nFileOS:@LF:"#FileType: ":nFileType:@LF:"#FileSubtype: ":nFileSubtype
   Pause( WbtPgm, Msg )

   Compiletime = FileVerInfo(WbtPgm, Lang, "CompileTime" )            ; Special to WinBatch Compiled EXE
   ToolsetBuildInfo = FileVerInfo(WbtPgm, Lang, "ToolsetBuildInfo" )  ; Special to WinBatch Compiled EXE
   ToolsetCopyright  = FileVerInfo(WbtPgm, Lang, "ToolsetCopyright" ) ; Special to WinBatch Compiled EXE
   Msg = "CompileTime: ":CompileTime:@LF:"ToolsetBuildInfo: ":ToolsetBuildInfo:@LF:"ToolsetCopyright: ":ToolsetCopyright
   Pause( WbtPgm, Msg )

Else
   Message( WbtPgm, "Sorry this script must be compiled into an EXE")
EndIf
Exit

Article ID:   W17691
Filename:   Determine Version of Compiler Used to Compile an EXE.txt
File Created: 2013:07:10:08:21:18
Last Updated: 2013:07:10:08:21:18