views:

701

answers:

1

I'm writing a console tool. Without privileges elevating for UAC support (manifest file), calling this tool from command prompt (cmd.exe) or console file manager (like far.exe) opens it in the same window, writes its output to the same window, etc.

But now, when manifest file was added, a new console windows is created for tool after UAC request dialog, so tool's output is written there, and window closes. No purpose for such tool being console.

How to fix that? What workarounds are there?

A: 

There is no way to "fix" that, as far as I know. This behavior is by design and is intended to ensure that any command line tool you elevate is not affected by any path modifications in the non-elevated command-line.

The idea is that in a normal day's work, people run any programs on their machines. These programs might modify the path for the user, so that a folder contains a malicious program named reg.exe for example is put before c:\windows\system32. Then the user runs an admin tool that requires elevation, the tool invokes reg.exe without specifying the path and voila - you're owned.

you should really consider getting the tool's output into a log file. Alternatively, you can develop the tool in two parts - a console tool that does not require elevation and a COM out-of-proc server that requires elevation.

Franci Penov