How to execute a exe with Admin account from a console application ?

G

Gilles LAMBERT

Hi,

I need to automize installation of exe and files on different versions
of Windows (except 95) from a console application. It includes shortcut
creation for all users wich requires more privileges then those of the
current user. So, does any body know if it's possible to run a exe with
more privilege than those of the connected user form a console
application ?

Thanks and best regards
Gilles
 
M

MSFT

Hi Gilles,

I have to say that you may not be able to achieve this without enough
privileges. Without Administrator's permission, you can't create short cut
for other people with a normal account.

Anyway, if you already know a local administrator's account and passqord,
you may execute the problem from "RunAs" command (only one Windows 2000, XP
and 2003), for more information on this, you can type "runas /?" in DOS
command line window, or refer to this article:

HOW TO: Enable and Use the "Run As" Command When Running Programs in Windows
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q294676

Hope this answer your question,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
H

Herfried K. Wagner [MVP]

Hello,

Gilles LAMBERT said:
I need to automize installation of exe and files on different
versions of Windows (except 95)

Huh... .NET applications won't run on Windows 95.
from a console application. It includes shortcut
creation for all users wich requires more privileges then
those of the current user. So, does any body know if it's
possible to run a exe with more privilege than those
of the connected user form a console application ?

You may use the 'ImpersonateLoggedOnUser' Win32-API function through
PInvoke:

VB6 sample (to be translated to VB.NET):

http://www.gssg.de/impers.zip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top