@@ -728,7 +728,9 @@ function HandleChangeThreadMode
728728{
729729 Write-Err " Windows Performance Recorder (WPR): Internal COM Error"
730730 Write-Warn " This issue usually resolves by restarting Windows."
731- Write-Warn " If this occurs frequently, make sure that you have a very recent version of WPR:`n "
731+ Write-Warn " If this occurs frequently, make sure that you have a very recent version of WPR."
732+ if (! $script :WPR_PreWin10 ) { Write-Warn " The current version is: $script :WPR_Win10Ver " }
733+ Write-Warn ' https://devblogs.microsoft.com/performance-diagnostics/wpr-start-and-stop-commands/#:~:text=0x80010106'
732734 WriteWPTInstallMessage " WPR.exe"
733735}
734736
@@ -872,6 +874,28 @@ Param (
872874}
873875
874876
877+ <#
878+ 0x80071069: The instance name passed was not recognized as valid by a WMI data provider.
879+ #>
880+ function HandleAbortedTrace
881+ {
882+ Param (
883+ $WprParams
884+ )
885+ Write-Err (GetCmdVerbose $script :WPR_Path $WprParams )
886+
887+ Write-Err " `n WPR returned error 0x80071069: The instance name passed was not recognized as valid by a WMI data provider.`n "
888+
889+ Write-Warn " This sometimes means that there is not enough space on the disk for the .ETL log file."
890+ Write-Warn " Intermediate trace files are stored here:"
891+ Write-Warn " `" $env: TRACE_PATH `" "
892+ Write-Warn
893+ Write-Warn " Try running 'cleanmgr' or clearing space on the disk."
894+ Write-Warn " Or set the TRACE_PATH environment variable to a folder on another drive."
895+ Write-Warn " Or simply try again to capture the trace using -Loop : TraceCPU Start -Loop ..."
896+ }
897+
898+
875899<#
876900 Use WMI (deprecated after PSv2) to return the SID of the logged-on user for the current Windows Session.
877901 Return: $Null if failure; $False if it's unchanged from the current context; [string]SID if success.
@@ -1865,17 +1889,19 @@ Param (
18651889
18661890 if ($TestRun )
18671891 {
1892+ # Skip stray, obviously old installations.
1893+ $fileVer = GetFileVersion $ExePath
1894+ if ($fileVer -and ($fileVer.Major -lt [Environment ]::OSVersion.Version.Major))
1895+ {
1896+ Write-Status " Found old v$fileVer at: $ExePath "
1897+ return $False
1898+ }
1899+
18681900 try
18691901 {
18701902 $Null = & $ExePath - ? 2> $Null | Out-Null # silent mode for PSv2+
1871- if ($? ) { $TestRun = $False } # Success!
18721903 }
18731904 catch
1874- {
1875- # Do not flag success.
1876- }
1877-
1878- if ($TestRun )
18791905 {
18801906 Write-Status " Test run failed: $ExePath "
18811907 return $False
@@ -1906,23 +1932,26 @@ Param (
19061932 Get the full path of the given executable from the Windows Performance Toolkit: WPA.exe, WPR.exe, etc.
19071933 This path can be customized with the WPT_PATH environment variable. ($Env:WPT_PATH may get cleared if it is invalid.)
19081934 ISSUE Win10/11+: WPR.exe exists in: $Env:windir\system32\wpr.exe Should this script search for another (newer?) version?
1935+ Consider Win10 installed with: WPR v10.0.19041 This is subject to: Error 0x80010106
1936+ https://devblogs.microsoft.com/performance-diagnostics/wpr-start-and-stop-commands/#:~:text=0x80010106
19091937#>
19101938function GetWptExePath
19111939{
19121940Param (
19131941 [string ]$Exe ,
19141942 [switch ]$Silent ,
1943+ [switch ]$Shallow ,
19151944 [switch ]$AltPath ,
19161945 [switch ]$TestRun
19171946)
1918- # Test the optional environment variable
1947+ # Test the optional environment variable. (Use the binary found on this path if at all possible.)
19191948 # This is set by the user. All others are set by the system or by an installer.
19201949
19211950 if ($env: WPT_PATH )
19221951 {
19231952 $WptPath = $env: WPT_PATH.Trim (' "' ).TrimEnd(' \' )
19241953 $WptPath = " $WptPath \$Exe "
1925- if (TestExePath $WptPath $ TestRun ([ref ]$AltPath )) { return $WptPath }
1954+ if (TestExePath $WptPath - TestRun: $False ([ref ]$AltPath )) { return $WptPath }
19261955
19271956 # Sanity check: If $env:WPT_PATH does not exist then reset is to null for this script.
19281957 if (! (Test-Path - PathType container - Path $env: WPT_PATH - ErrorAction:SilentlyContinue)) { $env: WPT_PATH = $Null }
@@ -1931,9 +1960,9 @@ Param (
19311960 # Test Windows Apps (not executable stubs)
19321961
19331962 # $Exe should exist in the folder registered under WPA.exe
1934- $PathReg = $Null
1963+ $WptPath = $ PathReg = $Null
19351964 $WpaOpenPath = " HKCU:\Software\Microsoft\Windows\CurrentVersion\App Paths\wpa.exe"
1936- $ WptPath = GetRegistryValue $WpaOpenPath " Path"
1965+ if ( ! $Shallow ) { $ WptPath = GetRegistryValue $WpaOpenPath " Path" }
19371966 if ($WptPath )
19381967 {
19391968 $WptPath = $PathReg = " $WptPath \$Exe "
@@ -1970,10 +1999,14 @@ Param (
19701999
19712000 # App store paths require Admin privilege to walk, unless you land directly on the app folder.
19722001 # Look up the path of the app folder(s) via the registry.
2002+ # This may only work for WPA.
19732003
1974- $WildPath = ' Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages\Microsoft.WindowsPerformanceAnalyzer*'
1975- [string []] $RegPaths = Get-Item - Path $WildPath - ErrorAction:SilentlyContinue
1976-
2004+ [string []]$RegPaths = $Null
2005+ if (! $Shallow )
2006+ {
2007+ $WildPath = ' Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages\Microsoft.WindowsPerformanceAnalyzer*'
2008+ $RegPaths = Get-Item - Path $WildPath - ErrorAction:SilentlyContinue
2009+ }
19772010 foreach ($RegPath in $RegPaths )
19782011 {
19792012 $Path = GetRegistryValue " Registry::$RegPath " ' PackageRootFolder'
@@ -1989,11 +2022,10 @@ Param (
19892022
19902023 # Test the system path, which may include WindowsApps (executable stubs, NO VERSION)
19912024
1992- $PathApps = $Null
19932025 $WptCmd = Get-Command - TotalCount 1 - CommandType Application $Exe - ErrorAction:SilentlyContinue
1994- if ( $WptCmd )
2026+ foreach ( $Cmd in $WptCmd )
19952027 {
1996- $WptPath = $PathApps = $WptCmd .Path
2028+ $WptPath = $PathApps = $Cmd .Path
19972029 if (TestExePath $WptPath $TestRun ([ref ]$AltPath )) { return $WptPath }
19982030 }
19992031
@@ -2002,7 +2034,7 @@ Param (
20022034 if ($Env: LOCALAPPDATA )
20032035 {
20042036 $WptPath = " $Env: LOCALAPPDATA \Microsoft\WindowsApps\$Exe "
2005- if (( $WptPath -ne $PathApps ) -and (TestExePath $WptPath $TestRun ([ref ]$AltPath ))) { return $WptPath }
2037+ if (! ( $WptCmd -contains $WptPath ) -and (TestExePath $WptPath $TestRun ([ref ]$AltPath ))) { return $WptPath }
20062038 }
20072039
20082040 # Try the Side-by-Side path for WPR
@@ -3211,6 +3243,18 @@ Param (
32113243 return [ResultValue ]::Error
32123244 }
32133245
3246+ 0x80071069 # The instance name passed was not recognized as valid by a WMI data provider.
3247+ {
3248+ HandleAbortedTrace $WprParams
3249+
3250+ Write-Msg " `n Canceling..."
3251+ $Null = InvokeWPR - Cancel - InstanceName $InstanceName
3252+
3253+ ListRunningProfiles
3254+
3255+ return [ResultValue ]::Error
3256+ }
3257+
32143258 default
32153259 {
32163260 Write-Err $script :WPR_Path @WprParams
0 commit comments