[wix-users] Custom Action firing

John Cooper JoCooper at jackhenry.com
Tue Oct 17 07:40:52 PDT 2017


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.



More information about the wix-users mailing list