0

我需要将 cdb.exe 作为进程调用,以检查几秒钟后终止进程。有些转储无法分析,所以我必须打另一个电话。在这里你可以看到我的代码。但它不起作用。cdb.exe 没有正确启动,我没有得到输出文件。

你对我有什么建议吗?实现流程部分的“之前”调用启动 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
4

2 回答 2

0

- 需要Passthru 才能使Wait-Process 工作。

我认为您还需要查看双引号字符串的扩展方式。 我认为$UnzippedFIle.Fullname 可能会在 zip 文件的实际全名末尾添加文字“.FullName”。我没有你的环境,但我所做的初步测试表明了这一点。尝试将其包装在一个子表达式中,例如:

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

让我知道情况如何。谢谢。

于 2020-02-25T15:46:11.213 回答
0
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
于 2020-02-26T19:14:19.800 回答