473,799 Members | 3,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4684
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.c om...
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*******@vbbo x.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
ProjectInstalle r pi = new ProjectInstalle r();
Hashtable stateSaver = new Hashtable();
pi.Install(stat eSaver);

but that throw an exception
the serviceProcessI nstaller 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*******@vbbo x.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
ProjectInstalle r pi = new ProjectInstalle r();
Hashtable stateSaver = new Hashtable();
pi.Install(stat eSaver);

but that throw an exception
the serviceProcessI nstaller 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(RAPIDHou seKeeper).Assem bly.Location;
string sInstallUtil = typeof(object). Assembly.Locati on;
sInstallUtil = sInstallUtil.Su bstring(0,
sInstallUtil.La stIndexOf(@"\") );
sInstallUtil += @"\InstallUtil. exe";

AppDomain dom = AppDomain.Creat eDomain("execDo m");
string[] asArgs = new string[1] {sExe};
dom.ExecuteAsse mbly(sInstallUt il, null, asArgs);

Vin
Nov 16 '05 #5
may i know where you coded it? is it inside the ProjectInstalle r.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
2015
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 XP? we have our software on thousands of XP boxes and have not had a problem up to this point. Any Clues/suggestions on what it could be? Regards, Jay
2
21915
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 successful. I'm now ready to start my service (I think) but the NET START command does not appear to indicate that the service is available to be run. The output for NET START is below as well. The Services list in the W2K administrator...
2
7988
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: System.IO.FileNotFoundException: File or assembly name windowsservice1, or one of its dependencies, was not found.. " I am new to C# environment. Any idea any clue will be appreciated. Thanks using System;
4
2932
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 have spent countless hours searching everything I can think of but I cannot solve this problem, so I post again with hopes that someone knows something that will put me on the right track.
2
4687
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 of the service is not set (this can be checked by right-clicking on the service in the Services window (Admin tools>Services), choosing Properties, LogOn tab). In order to enable my service to launch a GUI at startup, I added the following lines...
4
4185
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 check to see if the status is in stopped or running mode. But that doesn't tell me if it is actually running. I need to know this so that if it happens I can programmatically start the same service on another machine.
6
1174
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 a Visual Studio Command Prompt and issued the appropriate InstallUtil <path\executablecommand and the service runs perfectly on my development machine. What I can't figure out is how to install on it any other machine. Any pointers or links to...
3
3034
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 same assemblies and are part of the same solution. Installation of the Windows Service is optional and is to be installed on a single PC on a LAN, the desktop applications install to one or more pcs on the same LAN. Ive added the setup to my...
5
3311
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? Why do I need to set a property within my code to the service name? Are all these required or am I just doing this for consistency purposes?
1
2544
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 .NET or in Visual Basic 2005' http://support.microsoft.com/kb/317421 I've been able to program and run this example without problems. However, I wonder if I'm missing the point here. How do you deploy a service like this to a machine...
0
9541
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10484
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10228
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9072
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.