0

I'd like to execute 'vsjitdebugger.exe' for some process using the code below:

var myapp = Process.Start(@"path\to\myapp.exe");
Process.Start("vsjitdebugger.exe", $"-p {myapp.Id}").WaitForExit();

But failed.
The exit code is '-1' without showing the window.

What do I have to do in order to execute vsjitdebugger.exe?

UPATE #1
I'd like to attach debugger to the specific process only instantly.
That's why I profer code way instead of registry way.

To execute as administrator:

var myapp = Process.Start(@"path\to\myapp.exe");
Process.Start(new ProcessStartInfo()
{
     FileName = @"vsjitdebugger.exe",
     Arguments = "-p {myapp.Id}",
     Verb = "runas"
}).WaitForExit();

Failed as well after UAC screen.

exawon
  • 1
  • 2

1 Answers1

0

Lunching the just-in-time debugger through code will not work for you as you must run with admin privileges in order to use it.

What you can do, is start the debugger Automatically on your desired process.

I'd suggest reading more about the JIT of visual studio here as well before trying to execute process through C#.

This is not safe at all and considered bad practice. Unless there is an urgent need I would suggest maxing out all your other possibilities first.

Barr J
  • 10,636
  • 1
  • 28
  • 46