473,396 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Windows Service Install

Hi,

Is there a way of getting a C# windows service to install itself?

By this I mean the way C++ ones did

MyService.exe -service

Having to use the InstallUtil.exe will make installation programs a
bit more awkward (I know you can package it but that seems messy)

Vin
Nov 16 '05 #1
5 4659
Sure. You just have to write the code to do it. Services written in C++
never installed themselves magically; you had to take parameters in the
command line and muck with the service controller.

It should be much easier in C# though.
--
Klaus H. Probst, MVP
http://www.vbbox.com/

"Vincent Finn" <1@2.com> wrote in message
news:m1********************************@4ax.com...
Hi,

Is there a way of getting a C# windows service to install itself?

By this I mean the way C++ ones did

MyService.exe -service

Having to use the InstallUtil.exe will make installation programs a
bit more awkward (I know you can package it but that seems messy)

Vin

Nov 16 '05 #2
On Wed, 23 Jun 2004 11:31:41 -0700, "Klaus H. Probst"
<us*******@vbbox.com> wrote:
Sure. You just have to write the code to do it. Services written in C++
never installed themselves magically; you had to take parameters in the
command line and muck with the service controller.

It should be much easier in C# though.


That's the part I was wondering about

Is there a way to invoke the installer
I tried
ProjectInstaller pi = new ProjectInstaller();
Hashtable stateSaver = new Hashtable();
pi.Install(stateSaver);

but that throw an exception
the serviceProcessInstaller suceedes but the seviceInstaller fails
with "Object reference not set to an instance of an object."

Vin
Nov 16 '05 #3
On Wed, 23 Jun 2004 11:31:41 -0700, "Klaus H. Probst"
<us*******@vbbox.com> wrote:
Sure. You just have to write the code to do it. Services written in C++
never installed themselves magically; you had to take parameters in the
command line and muck with the service controller.

It should be much easier in C# though.


That's the part I was wondering about

Is there a way to invoke the installer
I tried
ProjectInstaller pi = new ProjectInstaller();
Hashtable stateSaver = new Hashtable();
pi.Install(stateSaver);

but that throw an exception
the serviceProcessInstaller suceedes but the seviceInstaller fails
with "Object reference not set to an instance of an object."

Vin
Nov 16 '05 #4
Got the solution (by created a managed C++ service and seeing what the
wizard gave me) so here it is in case anyone else is reading the
thread

string sExe = typeof(RAPIDHouseKeeper).Assembly.Location;
string sInstallUtil = typeof(object).Assembly.Location;
sInstallUtil = sInstallUtil.Substring(0,
sInstallUtil.LastIndexOf(@"\"));
sInstallUtil += @"\InstallUtil.exe";

AppDomain dom = AppDomain.CreateDomain("execDom");
string[] asArgs = new string[1] {sExe};
dom.ExecuteAssembly(sInstallUtil, null, asArgs);

Vin
Nov 16 '05 #5
may i know where you coded it? is it inside the ProjectInstaller.cs file
or is it under the Service.cs file itself?

thanks

-----------------------------------------------------------
when you fear to fail, you fear something that has not yet happened.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: jayderk | last post by:
a customer was trying to install some of our software after they installed the windows XP service pack 2 and he is getting a message that says something about it not being compatable with windows...
2
by: Mark | last post by:
I created an extremely simple windows service that only writes to the EventLogs on Stop and Pause. I installed it using the InstallUtil.exe program, the output of which is below. It appears to be...
2
by: Fan Wang | last post by:
Hi All, I wrote a windows service with C# as below. But I can't install it with installutil.exe. I got an error message " Exception occurred while initializing the installation:...
4
by: SQLScott | last post by:
My esteemed VB.Net gurus, I posted this question a week or so ago and recieved 1 response that helped me somewhat but really did not solve the problem (but I do appreciate the response). I...
2
by: letibal | last post by:
Hello, I have written a windows service and created an installer for it. The service runs under the system accounts. When started, it launches a GUI. By default, the InteractiveProcess property...
4
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to...
6
by: BK | last post by:
I've created a windows service and tested it. It works the way I want it to. I added a ProjectInstaller and set the appropriate properties in my Windows Service project. To install it, I went to...
3
by: Claire | last post by:
Hi (Visual studio 2005) My windows installer Setup project needs to install a desktop application plus an optional Windows Service, into a single destination folder. Both applications share the...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
1
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I am reviewing Windows service programming. I'm running VS2005 and programming in VB. I've just found an example in Support: 'How to create a Setup project for a Windows Service in Visual Basic...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.