473,378 Members | 1,218 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,378 software developers and data experts.

Installing Services

Hi there,
in the past when we have written services with C++, we used
to install them by running the .exe with command line parameters for
install/uninstall. Is this still possible with .Net? If this is not
possible, do I need to take the InstallUtil.exe with me to install on
customer site, or can I create a deployment package to do this for me?

Thanks.
Nov 16 '05 #1
7 4329
Well, I use the InstallUtil.exe

Install: C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\insta llutil
yourService.exe
Uninstall: C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\insta llutil /u
yourService.exe
"Waldy" <wa***@notmail.com> schrieb im Newsbeitrag
news:uj**************@TK2MSFTNGP15.phx.gbl...
Hi there,
in the past when we have written services with C++, we used
to install them by running the .exe with command line parameters for
install/uninstall. Is this still possible with .Net? If this is not
possible, do I need to take the InstallUtil.exe with me to install on
customer site, or can I create a deployment package to do this for me?

Thanks.

Nov 16 '05 #2
Yes, it's possible:

public void DoInstall(bool install)
{
// install or uninstall the service
using (TransactedInstaller ti = new TransactedInstaller())
{
using (Installer inst = CreateInstaller())
{
ti.Installers.Add(inst);
string path = "/assemblypath=" + Assembly.GetEntryAssembly().Location;
InstallContext ctx = new InstallContext(@"C:\install.log", new string[]
{ path });
ti.Context = ctx;

if (install)
{
Hashtable dict = new Hashtable();

try
{
ti.Install(dict);
}
catch (Exception e)
{
ti.Uninstall(null);
throw;
}
}
else
{
ti.Uninstall(null);
}
ti.Installers.Remove(inst);
}
}

May contain errors, this is a snippet from my own code.

HTH,
Stefan

"Waldy" <wa***@notmail.com> wrote in message
news:uj**************@TK2MSFTNGP15.phx.gbl...
Hi there,
in the past when we have written services with C++, we used
to install them by running the .exe with command line parameters for
install/uninstall. Is this still possible with .Net? If this is not
possible, do I need to take the InstallUtil.exe with me to install on
customer site, or can I create a deployment package to do this for me?

Thanks.

Nov 16 '05 #3
Hi,

No, you can but you don't have to

The best way to install a win service is including a Installer in the
project ( right click on the project name in the project explorer) and add a
Setup project to the solution, add a custom action consisting of the primary
output of the win service and you are really to go.

Ps : I have a link somewhere from MSDN for this approach I will look for it
in case you need further help

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Waldy" <wa***@notmail.com> wrote in message
news:uj**************@TK2MSFTNGP15.phx.gbl...
Hi there,
in the past when we have written services with C++, we used to install them by running the .exe with command line parameters for
install/uninstall. Is this still possible with .Net? If this is not
possible, do I need to take the InstallUtil.exe with me to install on
customer site, or can I create a deployment package to do this for me?

Thanks.

Nov 16 '05 #4
"Stefan Simek" <si********@kascomp.blah.sk> wrote in message
news:O9**************@TK2MSFTNGP10.phx.gbl...
Yes, it's possible:

public void DoInstall(bool install)
{
// install or uninstall the service
using (TransactedInstaller ti = new TransactedInstaller())
{
using (Installer inst = CreateInstaller())
{
ti.Installers.Add(inst);
string path = "/assemblypath=" + Assembly.GetEntryAssembly().Location;
InstallContext ctx = new InstallContext(@"C:\install.log", new string[]
{ path });
ti.Context = ctx;

if (install)
{
Hashtable dict = new Hashtable();

try
{
ti.Install(dict);
}
catch (Exception e)
{
ti.Uninstall(null);
throw;
}
}
else
{
ti.Uninstall(null);
}
ti.Installers.Remove(inst);
}
}

May contain errors, this is a snippet from my own code.

HTH,
Stefan


Hi Stefan,
the CreateInstaller() call does not appear to be part of
..Net. What code is in this function?

Thanks.
Nov 16 '05 #5
Stefan,
how did you get hold of the command line parameters as no args
are passed into main?

Nov 16 '05 #6

"Waldy" <wa***@notmail.com> wrote in message
news:u6****************@TK2MSFTNGP14.phx.gbl...
"Stefan Simek" <si********@kascomp.blah.sk> wrote in message
news:O9**************@TK2MSFTNGP10.phx.gbl...
Yes, it's possible:

public void DoInstall(bool install)
{
// install or uninstall the service
using (TransactedInstaller ti = new TransactedInstaller())
{
using (Installer inst = CreateInstaller())
{
ti.Installers.Add(inst);
string path = "/assemblypath=" + Assembly.GetEntryAssembly().Location;
InstallContext ctx = new InstallContext(@"C:\install.log", new
string[]
{ path });
ti.Context = ctx;

if (install)
{
Hashtable dict = new Hashtable();

try
{
ti.Install(dict);
}
catch (Exception e)
{
ti.Uninstall(null);
throw;
}
}
else
{
ti.Uninstall(null);
}
ti.Installers.Remove(inst);
}
}

May contain errors, this is a snippet from my own code.

HTH,
Stefan


Hi Stefan,
the CreateInstaller() call does not appear to be part of
.Net. What code is in this function?

Thanks.


Sorry, my fault... I just cut the previous snippet out, I didn't realize it
calls another...

The CreateInstaller() goes as follows, hope it should be complete now.

Installer CreateInstaller()
{
Installer inst = new Installer();

ServiceProcessInstaller spi = new ServiceProcessInstaller();
spi.Account = account;

ServiceInstaller si = new ServiceInstaller();
si.DisplayName = name;
si.ServiceName = name;
si.StartType = startMode;

inst.Installers.AddRange(new Installer[] { spi, si });

return inst;
}

HTH,
Stefan
Nov 16 '05 #7

"Waldy" <wa***@notmail.com> wrote in message
news:eD**************@TK2MSFTNGP15.phx.gbl...
Stefan,
how did you get hold of the command line parameters as no args
are passed into main?


What do you mean by: no args are passed into main?

If you need the arguments, declare your main function as:

public static void Main(string[] args)
{
...
}

If you need to retrieve the arguments somewhere else in your code, you can
use Environment.GetCommandLineArgs(), but beware, this also returns
executable name as the first element of the array, so it's not directly
interchangeable with the args passed to main...

HTH,
Stefan
Nov 16 '05 #8

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

Similar topics

2
by: y_oda2002 | last post by:
Hi everyone I was wondering if anyone could help me. I am trying to install ph so that i can learn the code. So far i havent had any problem installing apache. However when i try to get mysql...
1
by: Walter Jones | last post by:
I am currently using VB 4.0 with WindowsXP Home Edition and would like to continue to use it and also use Visual Basic.net The help file states that "Windows XP Home Edition provides limited...
1
by: ajackson | last post by:
i am having some trouble installing SQl server Reporting Services. well, in order to install the reporting services i have to install Service Pack 3a. so through my installation of package 3a i...
4
by: Claire | last post by:
Hi, I know this isn't strictly C# language related, but my service IS written in c# and I checked out the list of microsoft newsgroups for win2000 and couldn't really see one that applies. I'm...
1
by: Jeevan | last post by:
Hi, I am creating a Window Service in C-Sharp. The Window Service has a reference to an OCX file created in VC++. In OnStart method I have created an instance of the class, of the OCX file and...
2
by: J | last post by:
hi, I'm having a problem installing a service created in vb.net 2003 on a windows 2000 server. I have installed the service on a few XP machines with out any problems...but the 2 servers (win...
0
by: Anonieko Ramos | last post by:
Self Installing Service Enter a topic name to show or a new topic name to create; then press Enter .. Start by writing a service. This involves deriving a class from...
3
by: Mukesh | last post by:
Hi friends i wants to install a service (MS application Block) on the server using a web application. Can i do this if yes then how can i do this I m using MS VisualStudio.net 2003, C#, .net1.1...
15
by: =?Utf-8?B?RWxpb3Ro?= | last post by:
I try to install Windows Services but it show this error during the installation process, "Insufficient System resources exist to complete the requested service." I created this Services in VB...
2
by: Tam | last post by:
Im running into problems installing either VS 05 or 08 on a Vista Premium 64 bit machine and, ahem, it isnt going sweetly. When installing i get an "Error 1935.An error occured during the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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...

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.