Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nonadmin installation #297

Open
mrmattwilkins opened this issue Oct 18, 2024 · 5 comments
Open

Nonadmin installation #297

mrmattwilkins opened this issue Oct 18, 2024 · 5 comments
Assignees
Labels

Comments

@mrmattwilkins
Copy link

Would it be possible to add functionality so the MSI allows unprivileged non-admin installation into a users home folder?

@volks73
Copy link
Owner

volks73 commented Oct 18, 2024

This is possible, but not directly supported with a Command Line Interface (CLI) option or flag. A wix\main.wxs file can be created created for a project with the default template provided by this utility, cargo wix init. Then, the wix\main.wxs file can be opened in your favorite XML text editor and the <Directory Id='$(var.PlatformProgramFilesFolder)' Name='PFiles'> tag can be modified to install in user's home directory instead of the C:\Program Files\ location.

<Directory Id='$(var.PlatformProgramFilesFolder)' Name='PFiles'>

I am not sure about the exact variable to use to replace PlatformProgramFilesFolder but I found these references:

  1. https://stackoverflow.com/questions/9635813/how-can-i-reference-the-users-home-directory-in-wix
  2. https://stackoverflow.com/questions/19355537/wix-setting-install-folder-correctly
  3. https://learn.microsoft.com/en-us/windows/win32/msi/personalfolder

This cargo command is not actually generating the MSIs. It is using the WiX Toolset v3, and the subcommand is simply creating the configuration files for the WiX Toolset v3 based on a project's Cargo manifest and runs the compiler and linker applications. Thus, anything the WiX Toolset v3 can do, can be done with this tool through the WXS files.

The WiX Toolset v3 documentation is pretty extensive. A quick review of the references and WiX Toolset v3 documentation seems to indicate the Directory tab in question should be modified to:

<Directory Id='PersonalFolder' Name='PFiles'>

You only have to do this once after creating the WXS file. According to WiX Toolset's best practices, the WXS files should be treated like source code and added to version control.

@mrmattwilkins
Copy link
Author

Hi Christopher,

Thanks for looking into this.  And sorry it has taken a while for me to get to this (had a much needed break from work!).  I changed the Directory Id to PersonalFolder, but get some errors from light:

> cargo wix --nocapture
   Compiling inundate_win v0.1.0 (C:\Users\...blah...\inundate_win)
    Finished `release` profile [optimized] target(s) in 5.20s
Windows Installer XML Toolset Compiler version 3.14.1.8722
Copyright (c) .NET Foundation and contributors. All rights reserved.

main.wxs
Windows Installer XML Toolset Linker version 3.14.1.8722
Copyright (c) .NET Foundation and contributors. All rights reserved.

C:\Users\...blah...\inundate_win\wix\main.wxs(98) : error LGHT0204 : ICE38: Component License installs to user profile. It must use a registry key under HKCU as its KeyPath, not a file.
C:\Users\...blah...\inundate_win\wix\main.wxs(106) : error LGHT0204 : ICE38: Component Path installs to user profile. It must use a registry key under HKCU as its KeyPath, not a file.
C:\Users\...blah...\inundate_win\wix\main.wxs(116) : error LGHT0204 : ICE38: Component binary0 installs to user profile. It must use a registry key under HKCU as its KeyPath, not a file.
C:\Users\...blah...\inundate_win\wix\main.wxs(90) : error LGHT0204 : ICE64: The directory APPLICATIONFOLDER is in the user profile but is not listed in the RemoveFile table.
C:\Users\...blah...\inundate_win\wix\main.wxs(105) : error LGHT0204 : ICE64: The directory Bin is in the user profile but is not listed in the RemoveFile table.
C:\Users\...blah...\inundate_win\wix\main.wxs(99) : warning LGHT1076 : ICE91: The file 'LicenseFile' will be installed to the per user directory 'APPLICATIONFOLDER' that doesn't vary based on ALLUSERS value. This file won't be copied to each user's profile even if a per machine installation is desired.
C:\Users\...blah...\inundate_win\wix\main.wxs(117) : warning LGHT1076 : ICE91: The file 'exe0' will be installed to the per user directory 'Bin' that doesn't vary based on ALLUSERS value. This file won't be copied to each user's profile even if a per machine installation is desired.
Error[1] (Command): The 'light' application failed with exit code = 204

   Compiling inundate_win v0.1.0 (C:\Users\...\blah)
    Finished `release` profile [optimized] target(s) in 5.20s
Windows Installer XML Toolset Compiler version 3.14.1.8722
Copyright (c) .NET Foundation and contributors. All rights reserved.

main.wxs
Windows Installer XML Toolset Linker version 3.14.1.8722
Copyright (c) .NET Foundation and contributors. All rights reserved.

Any clues?

Cheers

Matt

@volks73
Copy link
Owner

volks73 commented Oct 24, 2024

In the template file, main.wxs, there are more than just the installation directory destination that need to be changed. The destination of the License file and such needs to also be updated. The default template assumes a "global" installation of the application, so a lot of the shortcuts, etc. are placed in "global" locations that require admin privileges. You might just want to remove all of the shortcuts, environment variables, and registry keys from the template. The cargo wix subcommand should still work.

The registry keys also need to be updated. The Root=HKCU needs to be used for the registry items.

Interesting because the WiX compiler finished successfully? Was a MSI created?

References:

  1. https://stackoverflow.com/a/13816363
  2. https://stackoverflow.com/a/16121097
  3. https://stackoverflow.com/a/24314535

@mrmattwilkins
Copy link
Author

Yes, good spotting, it did make an msi. I progressively removed stuff from that main.wxs until there was no files or license or keys to install. Unfortunately the installer still required admin privileges. I think I'm going to have to think of another way to distribute this. Cheers, thanks for your help.

@volks73
Copy link
Owner

volks73 commented Oct 25, 2024

Probably one other missing change: https://stackoverflow.com/a/14358274.

The main.wxs template is really intended for a "global" install to the Program Files location. In the past, this has been the majority use-case. If you are able to get a WXS file to work for PerUser without elevated privileges, I would be up for adding WXS file as a mustache template to this subcommand, i.e., a per-user.wxs, and then adding some functionality to select it versus the default since "per-user" installs seem to be more common lately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants