From: Ray Mitchell on
Hello,

I wrote a C# GUI application that I use to install, uninstall, start, and
stop arbitrary Windows services. Although I would like to have handled all
the gorey details in the C# code itself, I only found one example of how to
do this on the Internet and I could never get it to work properly. As an
alternative I decided to merely use the C# code as a GUI wrapper around
running the Microsoft "installutil.exe" executable as a process. As klugey
as it may seem it worked perfectly in all respects, but that was under
Windows XP. When I now try use this setup on Windows 7 I get the following
error message every time my C# application tries to run the installutil.exe
process: <The requested operation requires elevation: Installer file
"installutil.exe".> This apparently means that I somehow have to grant
administrator privileges to the running of installutil.exe, even though I'm
already logged on as administrator. So, I guess it really all boils down to
how to set the appropriate privileges for a process that is started from
within a C# application so it will work properly on Windows 7 (and I assume
Windows Vista too). Is there something I can change in my code so that it
sets the privileges appropriately to run this process?

As an aside, if anyone knows of some C# code that actually works directly to
install, uninstall, start, and stop arbitrary Windows services without the
need for installutil.exe at all, I would appreciate information on it.
However, I assume I will still need to deal with the administrator privilege
issue.

Thanks,
Ray
From: Mr. Arnold on


"Ray Mitchell" wrote:

> Hello,
>
> I wrote a C# GUI application that I use to install, uninstall, start, and
> stop arbitrary Windows services. Although I would like to have handled all
> the gorey details in the C# code itself, I only found one example of how to
> do this on the Internet and I could never get it to work properly. As an
> alternative I decided to merely use the C# code as a GUI wrapper around
> running the Microsoft "installutil.exe" executable as a process. As klugey
> as it may seem it worked perfectly in all respects, but that was under
> Windows XP. When I now try use this setup on Windows 7 I get the following
> error message every time my C# application tries to run the installutil.exe
> process: <The requested operation requires elevation: Installer file
> "installutil.exe".> This apparently means that I somehow have to grant
> administrator privileges to the running of installutil.exe, even though I'm
> already logged on as administrator. So, I guess it really all boils down to
> how to set the appropriate privileges for a process that is started from
> within a C# application so it will work properly on Windows 7 (and I assume
> Windows Vista too). Is there something I can change in my code so that it
> sets the privileges appropriately to run this process?

Windows Vista does not automatically assign Administrator privileges to
users, even if the user is an administrator. When performing tasks which
require administrator privileges, User Account Control (UAC) activates and
prompts the user for permission. The process is then elevated.

Windows 7 is Vista.
>
> As an aside, if anyone knows of some C# code that actually works directly to
> install, uninstall, start, and stop arbitrary Windows services without the
> need for installutil.exe at all, I would appreciate information on it.
> However, I assume I will still need to deal with the administrator privilege
> issue.

You what installutil.exe to run with the proper privileges within your
program, then I suspect you're going to have to set RunAsAdmin in the
properties of the exe itself. You do that by user Exploer.
From: Peter Duniho on
I wrote a reply previously, but it seems to have gotten blocked for some
reason. Rather than repost it (and have it blocked again), here's the
link to the Google-archived version:
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/msg/8fa563a126073dcc