Avatar of yyyannag
yyyannag
 asked on

Running standard c function system "Run as administrator"

Hello all

I'm trying to register my COM server programatically from c++ code using standard c function system (const char*), or alternatively any of the _exec* function family. It works fine under XP systems, however on Vista, it doesn't register the COM server. When I try to register my COM server directly from cmd ([serverpath] /regserver), I get no error at all, but the registration is not made. However, when I execute cmd.exe using the "Run as administrator" option, the registration succeeds.

My question is: How can I register my COM server on vista machines from the c++ code (perhaps using one of the _exec* functions with some special parameters)?
Editors IDEsC.NET Programming

Avatar of undefined
Last Comment
jkr

8/22/2022 - Mon
F. Dominicus

Maybe you can make use of:
http://www.codeguru.com/Cpp/misc/misc/system/article.php/c3805

Regards
Friedrich
alb66

To run an application as a different user you must us CreateProcessWithLogonW
http://msdn.microsoft.com/en-us/library/ms682431(VS.85).aspx
johnnash1180

Always start the application which registers com server through 'run as administrator'. The parent process's privilege will be elevated to child process as well.

If you wish to register through command prompt try start the command prompt [through shortcut?] through 'run as administrator' and then register com server. Also, you can use 'runas' command with desired user name details for registering your com server.

John Nash.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
jkr

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
jkr

I am not sure why you want to delete this Q, since it is answered.
jkr

I'd recomment http:#25106090 - since to me it seems the simplest way to address this problem, without asking the user for an admin password.