powershellwindbgcdb

Powershell: Call Debug Analyzer cdb.exe as Process


i need to call the cdb.exe as a Process to check to kill the process after a few seconds. Some Dumps cannot be analyzed so i have to do an other call. Here you can see my code. But it doesn't work. The cdb.exe is not started correctly and i am not getting the output file.

Do you have some advises for me? The call "before" implementing the process part starts the cdb.exe

   $maximumRuntimeSeconds = 3



            $path = "C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\cdb.exe"

            $process = Start-Process -FilePath $path "-z $unzippedFile.FullName, -c `".symfix;.reload;!analyze -v; q`""

            try {
                $process | Wait-Process -Timeout $maximumRuntimeSeconds -ErrorAction Stop > $outputFile
                Write-Warning -Message 'Process successfully completed within timeout.'
            }
            catch {
                Write-Warning -Message 'Process exceeded timeout, will be killed now.'
                $process | Stop-Process -Force
            }

            # call before implementing Process
            & "C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\cdb.exe" -z $unzippedFile.FullName -c ".symfix;.reload;!analyze -v; q" > $outputFile

Solution

  • -Passthru was needed to make Wait-Process work.

    You also need to look at how the double-quoted string is expanding. I think $UnzippedFIle.Fullname might be adding a literal ".FullName" at the end of the actual fullname of the zip file. I don't have your environment, but the rudimentary tests I've done show that. Try packing it in a sub-expression like:

    "-z $($unzippedFile.FullName), -c `".symfix;.reload;!analyze -v; q`""