CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2008
    Posts
    3

    Service installing

    Hey,
    I'm currently working on a program that needs to install other programs as services. I can't seem to find anything in C# to do this.
    Is there anything in C# that can do this? If not, what would be the best way to go about doing it? Calling an unmanaged api?

  2. #2
    Join Date
    Mar 2004
    Location
    33°11'18.10"N 96°45'20.28"W
    Posts
    1,808

    Re: Service installing

    yep, you gotta wrap the platform sdk for it. even then, the programs you install have to inherit ServiceBase and get run from main. I wrote a sample of how to do it. http://sanity-free.org/misc/ServiceInstaller.zip

    .net services have to implement a couple of installer classes, then you have to invoke the installutil executable that comes w/ the framework to install the service. If you use the platform sdk to install the services, you don't have to include the installer classes (only if you use installutil.exe).

  3. #3
    Join Date
    Sep 2008
    Posts
    3

    Re: Service installing

    Thanks for the reply and the services example. Maybe I'm misunderstanding part of your post. But the program I'm making is to install other programs, that I have no access to code for.
    Their not coded in .NET either, so there's no way for me to make them inherit servicebase.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Service installing

    It's not clear from your question whether the programs you wish to install were originally written as services? Were they?

  5. #5
    Join Date
    Sep 2008
    Posts
    3

    Re: Service installing

    No they were not, guess I should have also pointed that out.

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Service installing

    On the Win32 api level, an application written to be used as a service needs to expose some functions that the SCM (Service Control Manager) can tie into. In .Net these functions are supplied when you derive from ServiceBase. If the application wasn't originally written as a service, you aren't going to have these functions so the app can't function as a service. In other words, getting an application to run as a service is more than just installing it a certain way.

  7. #7
    Join Date
    Nov 2007
    Location
    .NET 3.5 / VS2008 Developer
    Posts
    624

    Re: Service installing

    are there .exe for you to run? how exactly are you wanting to "install" them?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured