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)?
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)?
To run an application as a different user you must us CreateProcessWithLogonW
http://msdn.microsoft.com/en-us/library/ms682431(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms682431(VS.85).aspx
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.
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.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
I am not sure why you want to delete this Q, since it is answered.
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.
http://www.codeguru.com/Cpp/misc/misc/system/article.php/c3805
Regards
Friedrich