PublicToken="1fc8b3b9a1e18e3b" Template=r"""!define MSVC_PUBLICTOKEN "" !define MSVC_VERSION "" !define MSVCR90_DLL "\x86_Microsoft.VC90.CRT_${MSVC_PUBLICTOKEN}_9.0.${MSVC_VERSION}_\msvcr90.dll" !define MSVCM90_DLL "\x86_Microsoft.VC90.CRT_${MSVC_PUBLICTOKEN}_9.0.${MSVC_VERSION}_\msvcm90.dll" !define MSVCP90_DLL "\x86_Microsoft.VC90.CRT_${MSVC_PUBLICTOKEN}_9.0.${MSVC_VERSION}_\msvcp90.dll" !define MSVC_CAT "\manifests\x86_Microsoft.VC90.CRT_${MSVC_PUBLICTOKEN}_9.0.${MSVC_VERSION}_.cat" !define MSVC_MANIFEST_PART "x86_Microsoft.VC90.CRT_${MSVC_PUBLICTOKEN}_9.0.${MSVC_VERSION}_.manifest" !define MSVC_MANIFEST "\manifests\${MSVC_MANIFEST_PART}" """ import glob,re,sys,os Files=glob.glob(r"c:\windows\winsxs\x86_Microsoft.VC90.CRT_%s_9.0.*"%PublicToken) SearchRe=re.compile(r"c:\\windows\\winsxs\\x86_Microsoft\.VC90\.CRT_%s_9\.0\.([0-9]+)\.([0-9]+)_(.*)"%PublicToken,re.I) MajorVersion=0 MinorVersion=0 LatestFile=None #Now Select the one with the latest version for File in Files: # Extract version Search=SearchRe.search(File) Major=int(Search.group(1)) Minor=int(Search.group(2)) if Major>MajorVersion: MajorVersion=Major MinorVersion=Minor LatestFile=File Suffix=Search.group(3) elif Major==MajorVersion and Minor>MinorVersion: MinorVersion=Minor LatestFile=File Suffix=Search.group(3) Template=re.sub("","%d.%d"%(MajorVersion,MinorVersion),Template) Template=re.sub("",PublicToken,Template) Template=re.sub("",Suffix,Template) WinSxsDir=os.path.join(os.getenv("systemroot"),"WinSxS") Template=re.sub("",WinSxsDir,Template) if len(sys.argv)==3 and sys.argv[2]=="1": Template=re.sub("","Debug",Template) else: Template=re.sub("","",Template) open("runtime","w").write(Template)