[wix-users] Custom Action firing

Habib Salim habib at hsalim.com
Wed Nov 1 07:25:43 PDT 2017


John,
Thanks for the help.
Sorry for the late reply - I got distracted by another project and dropped
the ball on thanking you.


-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf
Of John Cooper via wix-users
Sent: Tuesday, October 17, 2017 10:41 AM
To: 'WiX Toolset Users Mailing List' <wix-users at lists.wixtoolset.org>
Cc: John Cooper <JoCooper at jackhenry.com>
Subject: Re: [wix-users] Custom Action firing

Condition it on NOT Installed.

<InstallExecuteSequence>
      <Custom Action="CA_GetLogoPath" After="InstallInitialize">
          <![CDATA[NOT Installed]]>
      </Custom>
</InstallExecuteSequence>

--
John Merryweather Cooper
Senior Software Engineer -- Integration Development Group - Build &
Install Jack Henry & Associates, Inc.® | Lenexa, KS  66214 | Office: 
913-341-3434x431050 JoCooper at jackhenry.com




-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf
Of Habib Salim via wix-users
Sent: Tuesday, October 17, 2017 8:47 AM
To: 'WiX Toolset Users Mailing List' <wix-users at lists.wixtoolset.org>
Cc: Habib Salim <habib at hsalim.com>
Subject: [wix-users] Custom Action firing

The e-mail below is from an external source. Please do not open
attachments or click links from an unknown or suspicious origin.

Good Morning.



I have a custom action in my installer that prompts the user to select an
image file - a logo that will be used by the application.

The path to the image file is then stored in the application.config file.

(relavant code pasted below)



This works when I run the installer but it also runs on uninstall
(although it does nothing)

It also runs whenever a new user open the application for the first time.



How do I ensure that this opens only on the first install?



Regards

Habib



    <Property Id="LOGO_PATH" Value="C:\" />

    <Binary Id="HSalimCo.WixGetLogoDLL"
SourceFile="$(var.TargetDir)WixGetLogo.CA.dll" />

    <CustomAction Id="CA_GetLogoPath"

                  BinaryKey="HSalimCo.WixGetLogoDLL"

                  DllEntry="OpenFileChooser"

                  Execute="immediate"

                  Return="check" />



    <InstallExecuteSequence>

      <Custom Action="CA_GetLogoPath" After="InstallInitialize" />

    </InstallExecuteSequence>









public class CustomActions

    {

        [CustomAction]

        public static ActionResult OpenFileChooser(Session session)

        {

            try

            {

                session.Log("Begin OpenFileChooser Custom Action");

                var task = new Thread(() => GetFile(session));

                task.SetApartmentState(ApartmentState.STA);

                task.Start();

                task.Join();

                session.Log("End OpenFileChooser Custom Action");

            }

            catch (Exception ex)

            {



                session.Log("Exception occurred as Message: {0}\r\n
StackTrace: {1}", ex.Message, ex.StackTrace);

                return ActionResult.Failure;

            }

            return ActionResult.Success;

        }



        private static void GetFile(Session session)

        {

            var fileDialog = new WinForms.OpenFileDialog {

                Filter = "Image Files (*.TIF, *.PNG,
*.JPG)|*.TIF;*.PNG;*.JPG|All files(*.*) | *.* "

                , Title = "Select your logo -this image will appear on
your reports"



            };

            if (fileDialog.ShowDialog() == WinForms.DialogResult.OK)

            {

                session["LOGO_PATH"] = fileDialog.FileName;

            }

        }

    }


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

NOTICE: This electronic mail message and any files transmitted with it are
intended exclusively for the individual or entity to which it is
addressed. The message, together with any attachment, may contain
confidential and/or privileged information.
Any unauthorized review, use, printing, saving, copying, disclosure or
distribution is strictly prohibited. If you have received this message in
error, please immediately advise the sender by reply email and delete all
copies.


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


More information about the wix-users mailing list