Rahul
Rahul

Reputation: 2234

How to run a process as an administrator from Win32 \C++

I have a console application written in c#, which downloads a file to program files. So of course it needs to run as admin. This program gets called from a Win32 C++ application which almost certainly is not running as administrator
What are my options. How can I get this to work on UAC and non UAC enabled boxes ( I don't know if there needs to be separate solution in each case )
Oh and the console app is in .NET 2.0

Upvotes: 1

Views: 7888

Answers (2)

David Heffernan
David Heffernan

Reputation: 613481

On a machine with UAC you need to include a manifest resource to specify that you want the process to run as administrator.

On a machine without UAC you will simply have to instruct your users that they need to run it as a user in the administrators group. Almost all users of XP (the version that you will most commonly encounter without UAC) are in the administrators group so you won't encounter many problems.

Upvotes: 2

RED SOFT ADAIR
RED SOFT ADAIR

Reputation: 12238

I never tried it, but this can probably be done using the

CreateProcessAsUser Function.

Upvotes: 0

Related Questions