Well it took me about six hours of websearching and following false
leads to get the "pretty easy" custom action working, so just to try
and save anyone else the effort in the future...

I figured out almost immediately that you _can_ perform the action
fairly simply using the following:

<Property Id="NETEXE">net.exe</Property>
<CustomAction Id="StartMyService" Property="NETEXE" ExeCommand="start
lfs" Return="ignore" />

<InstallExecuteSequence>
<Custom Action="StartMyService"
After="InstallFinalize"><![CDATA[(&MyServiceFeature = 3)]]></Custom>
</InstallExecuteSequence>


However that way you get a command line window popping up in the
background as net.exe tries to start the service. I tried fiddling
around with a lot of the properties but couldn't get it to run
quietly. I finally found there's a specific function in wixca.dll to
run command line function quietly.

First you've got to find wixca.dll so you can either reference the
location or copy it into your project. In my case it was in C:\Program
Files (x86)\Windows Installer XML\bin. You then need something similar
to the following:

<Binary Id="wixca" src="wixca.dll"/>
<CustomAction Id="StartMyService" BinaryKey="wixca"
DllEntry="CAQuietExec" Execute="immediate" Return="ignore" />
<CustomAction Id="StartMyService.SetProperty" Property="QtExecCmdLine"
Value='"net" start MyService' />

(Note that it's required to have the extra set of quotes around "net"!)

<InstallExecuteSequence>
<Custom Action="StartMyService.SetProperty"
After="InstallFinalize"><![CDATA[(&MyServiceFeature = 3)]]></Custom>
<Custom Action="StartMyService"
After="StartMyService.SetProperty"><![CDATA[(&MyServiceFeature =
3)]]></Custom>
</InstallExecuteSequence>


Thanks to everyone who offered suggestions on how to get this worked out!

On Fri, Feb 22, 2008 at 4:03 PM, Alexander Shevchuk
<[EMAIL PROTECTED]> wrote:
> It should be pretty easy to accomplish with custom action type 34 scheduled 
> after InstallFinalize and with ExeCommand set to:
>  net start <servicename>
>
>
>  Alex
>
>
>
>
>
>  -----Original Message-----
>  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Geoff Finger
>  Sent: Friday, February 22, 2008 3:42 PM
>  To: wix-users@lists.sourceforge.net
>  Subject: Re: [WiX-users] Failing gracefully from ServiceControl?
>
>  That worked! When the service install fails the error box now has an
>  "Ignore" option. When I saw that option in the docs it never occurred
>  to me that it might also control the criticality of the item, I
>  figured turning it off would just make the installation continue on a
>  little further before it died. Thanks!
>
>  So does anyone know of a way to make it always choose "Ignore" without
>  popping up the window first?
>
>  And KStuart, when I first started looking into this problem I found a
>  couple posts from last year saying things like:
>
>  "The assemblies are not committed until successful execution of the
>  InstallFinalize Action. This means that if you author a custom action
>  or resource that relies on the assembly, it must be sequenced after
>  the InstallFinalize Action. For example, if you need to start a
>  service that depends on an assembly in the Global Assembly Cache
>  (GAC), you must schedule the starting of that service after the
>  InstallFinalize Action. This means you cannot use the ServiceControl
>  Table to start the service, instead you must use a custom action that
>  is sequenced after InstallFinalize."
>
>  That certainly seems to indicate that if I want the services to start
>  on a system where the assemblies haven't already been installed I'd
>  have to make a custom action to do it, and we probably don't have time
>  to deal with that before the release, which is why we're trying to get
>  the "fire and forget" method working.
>
>  On Fri, Feb 22, 2008 at 2:26 PM, Wilson, Phil
>  <[EMAIL PROTECTED]> wrote:
>  > It's possible that setting the ServiceControl Wait value to 0 might make a 
> difference. Generally speaking, this is the way you say you don't care if the 
> service starts properly or not.  However the documentation says that the SCM 
> needs to get the service into pending state, and I don't know off the top of 
> my head if this means the process has to at least start (and missing 
> dependencies could mean it doesn't).
>  >
>  >  Phil Wilson
>  >
>  >
>  >
>  >
>  >  -----Original Message-----
>  >  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of KStuart
>  >  Sent: Thursday, February 21, 2008 6:18 PM
>  >  To: wix-users@lists.sourceforge.net
>  >  Subject: Re: [WiX-users] Failing gracefully from ServiceControl?
>  >
>  >
>  >  I haven't been using windows installer/wix very long so am a little 
> confused,
>  >  from what I can see the default behaviour of the install sequence is to
>  >  process all files before attempting to start any services, therefore if 
> your
>  >  product includes dependent assemblies they will already have processed
>  >  before the StartServices action, in fact starting services is close to the
>  >  last action in the install sequence, of course you can always move it
>  >  further back.
>  >
>  >  If you're installing several services are you sure you don't have any
>  >  inter-service dependencies you're not taking care of?
>  >
>  >  You can always check if the dependencies are already installed and skip
>  >  trying to start the service if they are not, but like I said, if your
>  >  product is installing those assemblies anyhow it shouldn't be an issue.
>  >
>  >
>  >  Geoff Finger-2 wrote:
>  >  >
>  >  > I've got several services I'm trying to install. If I add
>  >  > "Start='install'" to the ServiceControl element then it will try to
>  >  > start them, but it will almost always fail with a 1920 error. I'm
>  >  > pretty sure this is because some of the services are dependent on
>  >  > side-by-side assemblies that are being installed at the same time and
>  >  > so won't be available until the install actually finishes.
>  >  >
>  >  > However is there a way to make it so that it will attempt to start the
>  >  > services but _not_ force a rollback if it fails? There are at least
>  >  > some circumstances where the assemblies might already have been
>  >  > installed by another package and it would be nice to at least make the
>  >  > attempt. There doesn't seem to be any "Vital" attribute for the
>  >  > ServiceControl element that I can set to "no." There is a "Vital" for
>  >  > ServiceInstall, but I can't set that to "no" even if it would fix the
>  >  > above problem, because it _is_ vital that they at least install
>  >  > properly, even if they don't start right away, and the same goes for
>  >  > "ErrorControl" in the ServiceInstall element as well I think.
>  >  >
>  >  > As an added bonus, if the above can be done is there also a way to do
>  >  > the service start step silently? We're expecting it to fail most of
>  >  > the time so there's no need to pop up an error message about it if it
>  >  > does.
>  >  >
>  >  > Thanks!
>  >  >
>  >  > And here's the code I've got in case it matters:
>  >  >
>  >  > <ServiceInstall Id="SystemServiceInstall"
>  >  > DisplayName="$(loc.IDS_SERVER) $(var.MAJORVER).$(var.MINORVER)"
>  >  > Description="$(loc.IDS_SERVER_SERVICE)
>  >  > $(var.MAJORVER).$(var.MINORVER)" Name="ServerService"
>  >  > ErrorControl="normal" Start="auto" Type="ownProcess" Vital="yes">
>  >  >       <ServiceDependency Id ="HTTP" />
>  >  > </ServiceInstall>
>  >  >
>  >  > <ServiceControl Id="SystemServiceControl" Name="ServerService"
>  >  > Start="install" Stop="uninstall" Remove="uninstall" />
>  >  >
>  >  > 
> -------------------------------------------------------------------------
>  >  > This SF.net email is sponsored by: Microsoft
>  >  > Defy all challenges. Microsoft(R) Visual Studio 2008.
>  >  > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>  >  > _______________________________________________
>  >  > WiX-users mailing list
>  >  > WiX-users@lists.sourceforge.net
>  >  > https://lists.sourceforge.net/lists/listinfo/wix-users
>  >  >
>  >  >
>  >
>  >  --
>  >  View this message in context: 
> http://www.nabble.com/Failing-gracefully-from-ServiceControl--tp15624384p15626152.html
>  >  Sent from the wix-users mailing list archive at Nabble.com.
>  >
>  >
>  >  -------------------------------------------------------------------------
>  >  This SF.net email is sponsored by: Microsoft
>  >  Defy all challenges. Microsoft(R) Visual Studio 2008.
>  >  http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>  >  _______________________________________________
>  >  WiX-users mailing list
>  >  WiX-users@lists.sourceforge.net
>  >  https://lists.sourceforge.net/lists/listinfo/wix-users
>  >
>  >
>  >
>  >  -------------------------------------------------------------------------
>  >  This SF.net email is sponsored by: Microsoft
>  >  Defy all challenges. Microsoft(R) Visual Studio 2008.
>  >  http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>  >  _______________________________________________
>  >  WiX-users mailing list
>  >  WiX-users@lists.sourceforge.net
>  >  https://lists.sourceforge.net/lists/listinfo/wix-users
>  >
>
>  -------------------------------------------------------------------------
>  This SF.net email is sponsored by: Microsoft
>  Defy all challenges. Microsoft(R) Visual Studio 2008.
>  http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>  _______________________________________________
>  WiX-users mailing list
>  WiX-users@lists.sourceforge.net
>  https://lists.sourceforge.net/lists/listinfo/wix-users
>
>  -------------------------------------------------------------------------
>  This SF.net email is sponsored by: Microsoft
>  Defy all challenges. Microsoft(R) Visual Studio 2008.
>  http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>  _______________________________________________
>  WiX-users mailing list
>  WiX-users@lists.sourceforge.net
>  https://lists.sourceforge.net/lists/listinfo/wix-users
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to