Redirect standard output and prompt for UAC with ProcessStartInfo

后端 未结 2 574
清酒与你
清酒与你 2020-12-06 15:26

I\'m working on a WPF application targeting .NET 3.0. I need to call an exe which requires administrative privileges. I can get the UAC to prompt for permission by using som

2条回答
  •  无人及你
    2020-12-06 16:14

    UseShellExecute must be set to false to redirect IO, and to true to use the Verb property. So you can't.

    But this article seems do the magic, although I haven't tested it.

    It's written in C++, but a wrapper API can easily be created to be called from C# by using DllImport.


    Note: If you want to pass data between the two programs and have access to the target program's source code, you can easily re-design you application to use Named Pipes instead of redirecting standard I/O.

提交回复
热议问题