Discussion:
Installing a Windows Service
(too old to reply)
SiJP
2006-05-11 16:04:29 UTC
Permalink
I have created a windows service, and can happily install it and run
it, but this involves manually running the InstallUtil command line
tool for each installation.

Can this not be automated to run from within my MSI?

Thanks

(vb.net, vs.net 2003, .net 1.1, windows xp sp2)
Michael Nemtsev
2006-05-11 16:43:56 UTC
Permalink
Hello SiJP,

Use ServiceInstaller class for this. See MSDN for more info

S> I have created a windows service, and can happily install it and run
S> it, but this involves manually running the InstallUtil command line
S> tool for each installation.
S>
S> Can this not be automated to run from within my MSI?
S>
S> Thanks
S>
S> (vb.net, vs.net 2003, .net 1.1, windows xp sp2)
S>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Michael Nemtsev
2006-05-11 18:01:32 UTC
Permalink
Hello Vadym,

Yep, but it's a bit out of the self intalling way

MN>> Use ServiceInstaller class for this. See MSDN for more info
MN>>
VS> Another way, without ServiceInstall, is to add values into
VS> ServiceInstall table in the msi file.
VS>
VS> To modify contents of .MSI file you can use Orca tool...
VS>
VS> If you use WiX then this will look like
VS>
VS> <ServiceInstall Id='ServiceExeFile'
VS> Name="[SERVICENAME]"
VS> DisplayName="[PRODUCTFAMILY]"
VS> Account="[SERVICE_LOGIN]"
VS> Password="[SERVICE_PASSWORD]"
VS> ErrorControl='normal' Start='auto'
VS> Type='ownProcess' Vital='yes'
VS> Description="Runs Flowfinity services. If this service
VS> is stopped, all Flowfinity-dependent applications will be
VS> unavailable." />
VS> <!-- Starts service -->
VS> <ServiceControl Id='ServiceExeFile' Name="[SERVICENAME]"
VS> Start="install" Stop="uninstall" Remove="both"
VS> Wait="yes" />
VS> --
VS> Regards, Vadym Stetsyak
VS> www: http://vadmyst.blogspot.com

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Phil Wilson
2006-05-12 00:18:51 UTC
Permalink
Actually it's not. MSI has built-in support for installing services and
starting and stopping them and related services. The ServiceInstall and
ServiceControl tables have been around for years. For some inexplicable (to
me) Visual Studio setup projects want to run code in ServiceInstaller
classes instead of just putting entries in those tables. This code is not
called directly - there's a shim Dll (InstallUtilLib) between the setup and
the installer class calls, so there's plenty of scope for obscure errors.
All the products that ever installed services with MSI used the Service
tables in the MSI file, then Visual Studio comes along and invents managed
custom action code to do something that was already there for free. Note
that it does not integrate with any other related products because things
installed with user code are not reference counted in MSI. My favorite setup
whine.

http://www.installsite.org/pages/en/msifaq/a/1044.htm

http://blogs.msdn.com/astebner/archive/2005/03/10/392280.aspx
--
Phil Wilson [MVP Windows Installer]
----
Post by Michael Nemtsev
Hello Vadym,
Yep, but it's a bit out of the self intalling way
MN>> Use ServiceInstaller class for this. See MSDN for more info
MN>> VS> Another way, without ServiceInstall, is to add values into
VS> ServiceInstall table in the msi file.
VS> VS> To modify contents of .MSI file you can use Orca tool...
VS> VS> If you use WiX then this will look like
VS> VS> <ServiceInstall Id='ServiceExeFile'
VS> Name="[SERVICENAME]"
VS> DisplayName="[PRODUCTFAMILY]"
VS> Account="[SERVICE_LOGIN]"
VS> Password="[SERVICE_PASSWORD]"
VS> ErrorControl='normal' Start='auto'
VS> Type='ownProcess' Vital='yes'
VS> Description="Runs Flowfinity services. If this service
VS> is stopped, all Flowfinity-dependent applications will be
VS> unavailable." />
VS> <!-- Starts service -->
VS> <ServiceControl Id='ServiceExeFile' Name="[SERVICENAME]"
VS> Start="install" Stop="uninstall" Remove="both"
VS> Wait="yes" />
VS> --
VS> Regards, Vadym Stetsyak
VS> www: http://vadmyst.blogspot.com
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche
SiJP
2006-05-12 09:30:53 UTC
Permalink
Thanks for the posts all..

Vadym & Michael - I have already created the serviceinstaller class..
_how_ can I use this to run the installutil? (e.g. code example maybe?)

I simply want my client to double click onthe MSI, click through the
installer UI, and voila, the service will be installed and up and
running.

arthernan - I haven't got vs.net 2005, as my original post indicates,
I'm using 2003.. bummer huh? :/

Phil - Great info.. haven't got a clue what you're on about. But this
is my knowledge gap rather than your explaination I'm sure! From
reading between the righteous rant, I think you make a point that
debugging is not the simplest of things to do with services. I would
agree, but I'm ok with that at the moment. You seem to agree with
Vadym & Michael that the ServiceInstaller is the way to go but haven't
said how to do it... could you expand on the 'how' side of things a
little pls?

cheers!

arthernan
2006-05-11 19:15:37 UTC
Permalink
Post by SiJP
Can this not be automated to run from within my MSI?
Yes it can, in VS 2005 it's actually pretty straight forward. Here is
the link I found

http://support.microsoft.com/kb/317421/en-us

It's actually a good article; Then the problem is debugging the service
because it needs to be running to be debugged. So you almost need to
stop the service, replace the executable, and restart the service.
Which can be pretty tedious and error prone when you debug. I made
another post on that.


http://groups.google.com/group/microsoft.public.dotnet.framework/browse_frm/thread/06bf8a513cbcb5d8/5b955850f68387ad#5b955850f68387ad
Loading...