0

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
Fabian
  • 23
  • 5
  • 1
    I doubt this is a WinDbg specific issue. Have you verified running complex command line args with a simple test app? Command line arguments including double quotes are hard to get right. More specific: are you sure that `$unzippedFile.FullName` has no spaces or has double quotes? – Thomas Weller Feb 25 '20 at 12:43
  • I'm not sure about the rest of the code, but $process is going to be null. You need to add the -PassThru param to the Start-Process command. This will the process object to get stored in the $Process variable. – Steven Feb 25 '20 at 12:49
  • @Steven: with -PassThru i'm getting an $Process Object. But it is not executing the cdb.exe. The $HasExited Property also is true. – Fabian Feb 25 '20 at 14:00

2 Answers2

0

-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.

Steven
  • 6,817
  • 1
  • 14
  • 14
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
blabb
  • 8,674
  • 1
  • 18
  • 27