How Can I Programatically Extract the Version of the Runtime?
As it says on the tin, how can I programmatically extract the runtime that is currently installed on a Windows Machine?
The reason this is required is we are trying to setup our Bamboo CI Agents (https://confluence.atlassian.com/bamboo/configuring-remote-agent-capabilities-using-bamboo-capabilities-properties-289276849.html) to contain additional capabilities based on certain versions of Synergy. We are trying to write scripts to help us automate the configuration of these agents and need the ability to know what version of the runtime we have installed to shove into a text file similar to the following:
system.synergy.sdi.version=11.1.1.5-2796 system.synergy.runtime32.version=10.03.0307 system.synergy.runtime64.version=10.03.0307
This information is then queried by Bamboo CI to understand what agents it can and cannot allocate to a particular task.
This was thrown together quickly, so in order for the registry lookups to work correctly it is important to build the code for X64.
If this is useful, you can grab the project at https://github.com/SteveIves/GetSynergyVersion
import System import System.Diagnostics import System.IO import Microsoft.Win32 namespace GetFileVersion ;;; <summary> ;;; Report the installed version of Synergy/DE. ;;; IMPORTANT: For the registry code to work correctly, build this .NET Console application for 64-bit ;;; </summary> main proc Console.WriteLine("32-bit Synergy: " + VersionTools.GetSynergy32Version()) Console.WriteLine("64-bit Synergy: " + VersionTools.GetSynergy64Version()) endmain public static class VersionTools private static patchLetters, [#]string, new string[#] {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"} public static method GetSynergy32Version, string proc mreturn GetSynergyVersion(Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Synergex\Install","SDELOC","")) endmethod public static method GetSynergy64Version, string proc mreturn GetSynergyVersion(Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Synergex\Install","SDELOC","")) endmethod private static method GetSynergyVersion, string required in sdeLocation, @object proc if (sdeLocation==^null) then begin mreturn "Not installed!" end else begin data dbrpath = Path.Combine(sdeLocation.ToString(),"dbl\bin\dbr.exe") data fvi = FileVersionInfo.GetVersionInfo(dbrpath) mreturn String.Format("{0}.{1}.{2}{3}",fvi.ProductMajorPart,fvi.ProductMinorPart,fvi.ProductBuildPart,patchLetters[fvi.ProductPrivatePart]) end endmethod endclass endnamespace
We use the Synergy function %versn and parse the output
Plus a whole heap of other stuff from within the system at runtime
@Steve The Registry Key is probably the most idea, the numeric format is more than good enough, the agent just needs to know what version it is on. Can we rely on those registry keys being there in the future?
Be aware though that we are considering a change in how we version label releases, possibly going to a build number scheme rather than patch letters. If that happens, the registry information would have to change accordingly.
Its important to have the location be known though that way the tooling can be standardized across versions.