473,395 Members | 1,462 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,395 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 4658
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.