[wix-users] My custom action fails to run sc.exe commands

Christopher Painter chrpai at iswix.com
Tue Nov 8 11:35:21 PST 2022


FWIW, windows service is one of my three core installation stories that I cover in the tutorials for my open source project.

https://github.com/iswix-llc/iswix-tutorials/tree/master/windows-service

I made a video 7 years ago that covers the above steps.  You can create the service, create the installer, build and test the install and uninstall in 2 minutes without writing any wix code by hand and without introducing failure points by using native MSI functionality.

https://www.youtube.com/watch?v=bxbcPnjfzIc  (No, this isn't a rickroll.)



________________________________
From: wix-users <wix-users-bounces at lists.wixtoolset.org> on behalf of Tigran Galoyan via wix-users <wix-users at lists.wixtoolset.org>
Sent: Friday, November 4, 2022 10:11 AM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Cc: Tigran Galoyan <tigran.galoyan at gmail.com>
Subject: Re: [wix-users] My custom action fails to run sc.exe commands

Thank you all for responses, it turned out it wasn't the deleting that
caused the issue, rather it was the step before when we try to stop a
service that was already stopped.

Will follow Herman's and Bob's advice to revisit the code later for
improvements.

Thanks,
Tigran



On Thu, Nov 3, 2022 at 3:40 PM Bob Arnson via wix-users <
wix-users at lists.wixtoolset.org> wrote:

> Or just use MSI's built-in support for services and not write any code at
> all?
>
> > -----Original Message-----
> > From: wix-users <wix-users-bounces at lists.wixtoolset.org> On Behalf Of
> > Herman van Drie via wix-users
> > Sent: Thursday, 3 November, 2022 15:24
> > To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
> > Cc: Herman van Drie <hvandrie at outlook.com>
> > Subject: Re: [wix-users] My custom action fails to run sc.exe commands
> >
> > As you're already executing from C# why not also write some (un) managed
> > code to stop, delete services from code instead of firing processes like
> SC -
> > which executes async without waiting for service action to complete.
> >
> > Sent from Surface Duo
> > ________________________________
> > From: wix-users <wix-users-bounces at lists.wixtoolset.org> on behalf of
> Nir
> > Bar via wix-users <wix-users at lists.wixtoolset.org>
> > Sent: Thursday, November 3, 2022 7:48:39 PM
> > To: wix-users at lists.wixtoolset.org <wix-users at lists.wixtoolset.org>
> > Cc: Nir Bar <nir.bar at panel-sw.com>
> > Subject: Re: [wix-users] My custom action fails to run sc.exe commands
> >
> > 1062 = ERROR_SERVICE_NOT_ACTIVEThe service has not been started.--Nir
> > BarWiX Expert ---- On Thu, 03 Nov 2022 18:28:29 +0200  wix-
> > users at lists.wixtoolset.org  wrote ----Hello Community,
> >
> > I have a custom action that is being run during the uninstall just
> before the
> > removal of files:
> >
> > *<Custom Action="CA_DeleteWindowsServices"
> > Before="RemoveFiles">REMOVE ~=
> > "ALL"</Custom>*
> >
> > And here is the declaration of my custom action in my main wxs file which
> > defines it as a deferred with impersonation set to NO:
> >
> > *<CustomAction Id="CA_DeleteWindowsServices" Return="check"
> > BinaryKey="ESInstallerCustomActions"
> > DllEntry="CAM_DeleteWindowsServices"
> > Execute="deferred" Impersonate="no" />*
> >
> > The custom action implementation (C#) is quite simple, it just deletes
> some
> > windows services using the command "sc.exe delete my_service_name"
> > (Process.Start).
> >
> > The thing is, that on some computers it runs well and on some computers
> it
> > fails to delete the services, and when I check the installer log, where
> I trace
> > the exception if deletion fails then I see this logged error:
> >
> > *Network shell process exited with code1062*
> >
> > Any ideas what I need to do or what I am missing? If needed I can share
> the
> > code for the custom action as well, although as I mentioned it's a
> simple code
> > using sc.exe delete option.
> >
> > Thanks in advance,
> > Tigran
> >
> > ________________________________________________________________
> > ____
> > WiX Toolset Users Mailing List provided by FireGiant
> > http://www.firegiant.com/
> >
> > ________________________________________________________________
> > ____
> > WiX Toolset Users Mailing List provided by FireGiant
> > http://www.firegiant.com/
> >
> > ________________________________________________________________
> > ____
> > WiX Toolset Users Mailing List provided by FireGiant
> > http://www.firegiant.com/
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
>

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/


More information about the wix-users mailing list