tony
tony

Reputation: 137

How to start exe file cdb.exe and pass argument from process.start

If I do the following manually it works fine but I must be able to do the same from C# and in addition be able to close the command window.

  1. Open the command window(cmd)
  2. use cd to go to the directory where the cdb.exe is located which is in my case C:\Program Files (x86)\Windows Kits\8.1\Debuggers\x86
  3. I do cdb -z D:\Temp\CrashDump.dmp -logo c:\temp\mydump.text -c "q"
  4. Now there is a mydump.textin c:\temp\

So I want to do the same from C#. I have tried several solutions. Here is the first one

Process.Start(@"program files (x86)\windows Kits\8.1\Debuggers\x86\cdb.exe", @"-z D:\Temp\CrashDump.dmp -logo c:\temp\mydump.text -c \\""q\\""");

This gives error when executed saying "The system cannot find the specified file.

My second attempt is

 Process.Start("cmd.exe", @"program files (x86)\windows Kits\8.1\Debuggers\x86\cdb.exe -z D:\Temp\CrashDump.dmp -logo c:\temp\mydump.text -c \\""q\\""");

This open the command window but doesn't create the file mydump.text which it should.

I have also tried to add the command to a bat file but it will not work.

The command window should also be closed automatically after the file mydump.text has been created.

Upvotes: 2

Views: 604

Answers (1)

Arctic
Arctic

Reputation: 827

You can try this

        using (var process = new System.Diagnostics.Process())
        {
            var startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.FileName = @"C:\Program Files (x86)\Windows Kits\8.1\Debuggers\x86\cdb.exe";
            startInfo.Arguments = @"-z D:\Temp\CrashDump.dmp -logo c:\temp\mydump.text -c ""q""";
            process.StartInfo = startInfo;
            process.Start();    
        }

Upvotes: 1

Related Questions