@@ -438,64 +438,37 @@ BOOL CUIforETWDlg::OnInitDialog()
438438 auto xperfVersion = GetFileVersion (GetXperfPath ());
439439 constexpr int64_t requiredXperfVersion = (10llu << 48 ) + 0 + (10586llu << 16 ) + (15llu << 0 );
440440 // Windows 10 spring 2019 version, 10.0.18362.1 - requires Windows 8 or higher?
441- constexpr int64_t preferredXperfVersion = (10llu << 48 ) + 0 + (18362llu << 16 ) + (1llu << 0 );
441+ constexpr int64_t preferredXperfVersion = (10llu << 48 ) + 0 + (22000llu << 16 ) + (194llu << 0 );
442442
443443 wchar_t systemDir[MAX_PATH];
444444 systemDir[0 ] = 0 ;
445445 GetSystemDirectory (systemDir, ARRAYSIZE (systemDir));
446446 std::wstring msiExecPath = systemDir + std::wstring (L" \\ msiexec.exe" );
447447
448- if (Is64BitWindows () && PathFileExists (msiExecPath.c_str ()))
448+ if (IsWindowsTenOrGreater () && Is64BitWindows () && PathFileExists (msiExecPath.c_str ()))
449449 {
450450 // The installers are available as part of etwpackage.zip on
451451 // https://github.com/google/UIforETW/releases
452- if (IsWindowsSevenOrLesser ())
452+ // Install 64-bit WPT 10 if needed and if available.
453+ if (xperfVersion < preferredXperfVersion)
453454 {
454- // The newest (Anniversary Edition or beyond) WPT doesn't work on Windows 7.
455- // Install the older 64-bit WPT 10 if needed and if available.
456- if (xperfVersion < requiredXperfVersion)
455+ const std::wstring installPath10 = CanonicalizePath (GetExeDir () + L" ..\\ third_party\\ wpt10\\ WPTx64 (DesktopEditions)-x86_en-us.msi" );
456+ if (PathFileExists (installPath10.c_str ()))
457457 {
458- const std::wstring installPathOld10 = CanonicalizePath (GetExeDir () + L" ..\\ third_party\\ oldwpt10\\ WPTx64-x86_en-us.msi" );
459- if (PathFileExists (installPathOld10.c_str ()))
458+ ChildProcess child (msiExecPath);
459+ std::wstring args = L" /i \" " + installPath10 + L" \" " ;
460+ child.Run (true , L" msiexec.exe" + args);
461+ const DWORD installResult10 = child.GetExitCode ();
462+ if (!installResult10)
460463 {
461- ChildProcess child (msiExecPath);
462- std::wstring args = L" /i \" " + installPathOld10 + L" \" " ;
463- child.Run (true , L" msiexec.exe" + args);
464- const DWORD installResult10 = child.GetExitCode ();
465- if (!installResult10)
466- {
467- outputPrintf (L" WPT version 10.0.10586 was installed.\n " );
468- }
469- else
470- {
471- outputPrintf (L" Failure code %u while installing WPT 10.\n " , installResult10);
472- }
464+ xperfVersion = GetFileVersion (GetXperfPath ());
465+ outputPrintf (L" WPT version %llu.%llu.%llu.%llu was installed.\n " ,
466+ xperfVersion >> 48 , (xperfVersion >> 32 ) & 0xFFFF ,
467+ (xperfVersion >> 16 ) & 0xFFFF , xperfVersion & 0xFFFF );
473468 }
474- }
475- }
476- else
477- {
478- // Install 64-bit WPT 10 if needed and if available.
479- if (xperfVersion < preferredXperfVersion)
480- {
481- const std::wstring installPath10 = CanonicalizePath (GetExeDir () + L" ..\\ third_party\\ wpt10\\ WPTx64-x86_en-us.msi" );
482- if (PathFileExists (installPath10.c_str ()))
469+ else
483470 {
484- ChildProcess child (msiExecPath);
485- std::wstring args = L" /i \" " + installPath10 + L" \" " ;
486- child.Run (true , L" msiexec.exe" + args);
487- const DWORD installResult10 = child.GetExitCode ();
488- if (!installResult10)
489- {
490- xperfVersion = GetFileVersion (GetXperfPath ());
491- outputPrintf (L" WPT version %llu.%llu.%llu.%llu was installed.\n " ,
492- xperfVersion >> 48 , (xperfVersion >> 32 ) & 0xFFFF ,
493- (xperfVersion >> 16 ) & 0xFFFF , xperfVersion & 0xFFFF );
494- }
495- else
496- {
497- outputPrintf (L" Failure code %u while installing WPT 10.\n " , installResult10);
498- }
471+ outputPrintf (L" Failure code %u while installing WPT 10.\n " , installResult10);
499472 }
500473 }
501474 xperfVersion = GetFileVersion (GetXperfPath ());
@@ -551,6 +524,8 @@ BOOL CUIforETWDlg::OnInitDialog()
551524 // that Python scripts which rely on xperf.exe being in the path will fail.
552525 // This adds the WPT10 directory to the path. We could just do this when WPT
553526 // has been freshly installed but this seems cleaner.
527+ // We add it to the end of the path so that it won't affect systems that
528+ // already have WPT in the path, perhaps from the store.
554529 auto path = GetEnvironmentVariableString (L" path" );
555530 path += L' ;' + wpt10Dir_;
556531 SetEnvironmentVariable (L" path" , path.c_str ());
0 commit comments