oleg-shilo / wixsharp

Framework for building a complete MSI or WiX source code by using script files written with C# syntax.
MIT License
1.12k stars 175 forks source link

Opening .exe from AfterInstall event behaves different in combination with registry than starting .exe as normal. #1640

Closed ejongejans closed 2 months ago

ejongejans commented 2 months ago

Hi,

I'm trying to open our installed .exe, after installing it. With the code below. That works fine.

But somehow I get a dialog from our licensing library (integrated in .exe), saying it's in evaluation mode of our software. There is a valid license installed in in the local user registry.

But somehow, when the process is started from the installer it can't access that registry key and looks somewhere else. Where i'm not sure at the moment.
How to prevent that? Or what exactly is different when a .exe is started from the .msi like this?

I've tried to set the InstallPrivileges to limited, but that doesnt' seem to make a difference.

Of course, when I start the installed .exe as normal; it doesn't happen and it finds the installed license correctly.

OS: windows 10, up to date.

Thanks for any help

kind regards Elco

wixproject.DefaultDeferredProperties += ",WAssemblyName";
**wixproject.InstallPrivileges = InstallPrivileges.limited;**
wixproject.AfterInstall += args =>
{
    if (args.IsInstalling)
    {
        try
        {
            string exeName = args.Session.Property("WAssemblyName") + ".exe";
            string exePath = args.InstallDir.PathCombine(exeName);
            if (DialogResult.Yes == MessageBox.Show("Would you like to start the program after finishing the install?" + Environment.NewLine + Environment.NewLine + exePath, "Start software?", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                System.Diagnostics.Process.Start(exePath);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show("Could not start the software: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
};
Torchok19081986 commented 2 months ago

Hallo, somehow it looks like your exe search in wrong registry TreeView. There is x86 and x64 Registry TreeView. There is example from oleg, for x64-Registry Treeview or x64-Bit Process. Just search in Release source code and try it. MSI is always x86 and your process, maybe compiled for x64.

maybe this link helps : https://stackoverflow.com/questions/974038/reading-64bit-registry-from-a-32bit-application

best regarsds, Torchok.

oleg-shilo commented 2 months ago

MSI is always x86 and your process, maybe compiled for x64.

Correct. MSI session is always x86 since it is x86 Windows service. This is the limitation of MSI technology.

ejongejans commented 2 months ago

Hi,

I don't have direct access to the registry location code. (bought component :S ) There is in that case nothing to do about it correct?

But what I don't understand is why does my 64bit app startup as 32bit? There is just 1 .exe installed in the program files, and this is a .NET8 app, compiled for 64bit.

Is the MSI forcing that as a 32bit process somehow?

And chaining something with a new launcher.exe in the middle that starts the final .exe wouldn't help either I guess.. ?

thx Elco

Torchok19081986 commented 2 months ago

according to MS : NET Framework cant be used together with .NET 7+ or higher. your WixSharp outgoing MSI is build in .NET Framework, but your components are in .NET 8 . It can be, that msi doesnt find your .NET 8 Registry components, because of different NET Framwework Architecture. If so, you will need to use Wixv4 with WixSharp v4. There is no another solution, i'm afraid.

ejongejans commented 2 months ago

Ok thanks! Then it will be a future todo when we rebuild the licensing library.

kind regards Elco