简体   繁体   中英

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

-Passthru was needed to make Wait-Process work.

I think 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 rudementary tests I've done show that. Try packing it in a sub-expression like:

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

Let me know how that goes. Thanks.

C:\>dir /b ok.txt
File Not Found

C:\>type dodump.ps1

$path = "C:\Program Files\Windows Kits\10\Debuggers\x86\cdb.exe"
$process = Start-Process -PassThru -FilePath $path -ArgumentList "-z `"C:\calc.DMP`"" ,
 "-c `".symfix;.reload;!analyze -v;q`"" -RedirectStandardOutput c:\\ok.txt

try {
$process | Wait-Process -Timeout 100 -ErrorAction Stop
Write-Host "Process finished within timeout"
}catch {
$process | Stop-Process
Write-Host "process killed"
}
Get-Content  C:\ok.txt |Measure-Object -Line

C:\>powershell -f dodump.ps1

Process finished within timeout
Lines Words Characters Property
139

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM