2

I am using bare Win32Api. I need to launch app with elevated permissions and app has no manifest. So, the only way is to use ShellExecuteEx with runAs verb. It works, but I need to read process stdout. With CreateProcess I have STARTUPINFO which I can use to pipe process stdout.

But ShellExecuteEx does not have such API. So, how can I elevate and redirect stdout?

user996142
  • 2,753
  • 3
  • 29
  • 48

1 Answers1

1

This is not possible. To read stdout CreateProcess is required. But CreateProcess can't start another process elevated...

If possible create your own process that you may launch elevated. This process may capture stdout. Use some IPC to communicate with this process to get the stdout.

Or using simple pipe redirection.

This question has already been asked and is a duplicate to. See also this question about elevating.

Community
  • 1
  • 1
xMRi
  • 14,982
  • 3
  • 26
  • 59
  • 1
    "*CreateProcess can't start another process elevated*" - true, but [`CreateProcessElevated()`](https://www.codeproject.com/Articles/19165/Vista-UAC-The-Definitive-Guide) can. – Remy Lebeau Mar 01 '17 at 17:35