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

Setup project - stop a service?

I have a setup project that copies a bunch of files, a small management
program, and also another .exe (that is run by a custom action) to install
and start a service.

Works fine first time, but the second time (i.e a user upgrades) the
installer cannot overwrite the service .exe as it is in use. Is there any
way to get the setup project to stop the service before copying the files
etc?

Thanks!

Oct 16 '07 #1
3 3497
Hi JamesB,

Try:
ServiceController sc = new ServiceController("ServiceName");
sc.Stop();

Hope this helps :)
--
_____________
Adam Bieganski
http://godevelop.blogspot.com
"JamesB" wrote:
I have a setup project that copies a bunch of files, a small management
program, and also another .exe (that is run by a custom action) to install
and start a service.

Works fine first time, but the second time (i.e a user upgrades) the
installer cannot overwrite the service .exe as it is in use. Is there any
way to get the setup project to stop the service before copying the files
etc?

Thanks!

Oct 16 '07 #2

"Adam Bieganski" <abieganski(at)gmail.comwrote in message
news:D8**********************************@microsof t.com...
Hi JamesB,

Try:
ServiceController sc = new ServiceController("ServiceName");
sc.Stop();
The code makes sense - but where can I put that in a setup project? (Sorry,
I'm not too clever at setup stuff!)

Oct 16 '07 #3
You have to create a class that inherits from
System.Configuration.Install.Installer - it can be in the same project as the
NT Service that you are installing.

Then you override then Install method and execute the service stopping code
in there, before calling the base Install implementation.

Something like this:

[RunInstaller(true)]
public class ProjectInstaller : Installer
{
public override void Install(IDictionary stateSaver)
{
// stop the service here
ServiceController ....

// now let the installer do its job
base.Install(stateSaver);
}
}
Cheers,
_____________
Adam Bieganski
http://godevelop.blogspot.com
"JamesB" wrote:
>
"Adam Bieganski" <abieganski(at)gmail.comwrote in message
news:D8**********************************@microsof t.com...
Hi JamesB,

Try:
ServiceController sc = new ServiceController("ServiceName");
sc.Stop();
The code makes sense - but where can I put that in a setup project? (Sorry,
I'm not too clever at setup stuff!)

Oct 16 '07 #4

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

Similar topics

1
by: Alireza Haghshenass | last post by:
Dear All, I just wanted to know, how can I register a service using Visual studio setup project. I can create a Setup Project successfully, it installs all the program, but I need a hint on how to...
1
by: Philip Wagenaar | last post by:
I have a Visual Studio Solution with 4 four projects. 1) class library 2) console app 3) windows service 4) setup project The console app en and the windows service both use the dll from the...
0
by: JM | last post by:
I have created simple windows service which just write message to event log when it starts and stops. I am able to install it succesfully using: installutil <service_file.exe>, where...
1
by: rohan_from_mars | last post by:
I have a windows service and am also using Enterprise Library June 2005 version. Now i have created Setup and Deployment Project which installs the service. but how do i add EL dlls-...
6
by: andrewbb | last post by:
I want to deploy a service with a windows app and the setup program must conform to the Vista certification requirements. Can that be done with the standard .net setup project? Assuming cost is...
2
by: =?Utf-8?B?Um9nZWxpbw==?= | last post by:
I know this has been answered, I just can't find it. can someone point me to a URL or thread that shows how to install a web service in a Windows Setup Project ? I need to install a windows app,...
0
by: henkya | last post by:
Language Used: C# Project Typed: Setup Project (for .NET Window Service) Hi Bump into this issue and seriously have a hunch that this is a bug in the .NET setup project. These are the scenario:...
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...
4
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi all, I continue with installation. I create three windows services. Each service has a Installer class.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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
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
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.