2

I am trying to create a windows installer .msi file with the wix toolkit that is supposed to be used as an advanced self-extractor. So it is supposed to create some folders and extract files without leaving any other traces on the target system. This means that there will also be no uninstall at all for the package.

Here Microsoft is stating that removing some actions form the InstallExecuteSequence and AdvertiseExecuteSequence tables would do the trick.

adding-and-removing-an-application-and-leaving-no-trace-in-the-registry

Additionally I had to set all the Components GUIDs to a Nullstring to prevent Component registration and I set the DISABLEROLLBACK and MSIFASTINSTALL properties to appropriate values in order to prevent rollback and system restore point data from being stored.

Nevertheless I do not seem to be able to prevent Windows Installer from creating registry entries for each folder it creates. These will all be found under the Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Folders.

Here is an image of registry values being written and deleted. All values but the values under \Folders are being reset. Meaning the \Folders values will forever be left on the target system.

RegValues written and deleted during installation

Does anyone know a way to prevent Windows Installer from creating these registry entries when creating directories? Or maybe someone knows a workaround to create the directories in another manner, where no registry entries would be set.

Here is the full content of my .wxs file for the wix toolset.

<?xml version='1.0' encoding='windows-1252'?>
<!-- This code has been adapted from firegiant's wix user interface tutorial: https://www.firegiant.com/wix/tutorial/user-interface/first-steps/ -->
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>

  <Product Name='WixExtract' Id='591E9F05-2F1E-4121-8263-B9ADEDFE0746' UpgradeCode='C017D87A-1C2B-4970-8F4C-BA4DADAB6F2F'
    Language='1033' Codepage='1252' Version='1.0.0' Manufacturer='Some Inc.'>

    <Package Id='*' Description='WixExtract Test' InstallScope = 'perUser'
      Comments='This is a test extractor' Manufacturer='Some Inc.'
      InstallerVersion='500' Languages='1033' Compressed='yes' SummaryCodepage='1252' />

    <Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
    <Property Id='DiskPrompt' Value="WixExtract Test [1]" />

    <Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='ProgramFilesFolder' Name='PFiles'>        
        <Directory Id='INSTALLDIR' Name='WixExtract'>

          <!-- add a test file -->
          <!-- Setting the GUID to a Nullstring will prevent Components from being registered -->
          <Component Id='File1' Guid=''>
             <File Id='File1TXT' Name='file1.txt' DiskId='1' Source='file1.txt' KeyPath='no' />
          </Component>

          <!-- create a test subfolder -->
          <Directory Id='SUBFOLDER1' Name='SubFolder1'>
            <Component Id="CreateSubFolder1" Guid=""
              SharedDllRefCount="no" KeyPath="no" NeverOverwrite="no" Permanent="no" Transitive="no"
              Win64="no" Location="either">
              <CreateFolder/>
            </Component>
          </Directory>

        </Directory>        
      </Directory>      
    </Directory>

    <Feature Id='Complete' Title='WixExtract' Description='Everything.'
      Display='expand' Level='1' ConfigurableDirectory='INSTALLDIR' AllowAdvertise = 'no'>
      <Feature Id='MainProgram' Title='Program' Description='A test file and a folder.' Level='1' AllowAdvertise = 'no'>
        <ComponentRef Id='File1' />
        <ComponentRef Id='CreateSubFolder1' />
      </Feature>    
    </Feature>

    <!-- This should prevent rollback scripts from being created https://learn.microsoft.com/en-us/windows/desktop/msi/-disablerollback -->
    <Property Id='DISABLEROLLBACK'>1</Property>

    <!-- This should disable system restore points and file costing https://learn.microsoft.com/de-de/windows/desktop/Msi/msifastinstall-->
    <Property Id='MSIFASTINSTALL'>4</Property>

    <!-- suppressing the following actions severely reduces the reg values being written https://learn.microsoft.com/en-us/windows/desktop/msi/adding-and-removing-an-application-and-leaving-no-trace-in-the-registry -->
    <InstallExecuteSequence>
        <RegisterProduct Suppress='yes' />
        <RegisterUser Suppress='yes' />
        <PublishProduct Suppress='yes' />
        <PublishFeatures Suppress='yes' />
    </InstallExecuteSequence>

    <AdvertiseExecuteSequence>        
        <PublishProduct Suppress='yes' />
        <PublishFeatures Suppress='yes' />
    </AdvertiseExecuteSequence>

    <UIRef Id="WixUI_Mondo" />
    <UIRef Id="WixUI_ErrorProgressText" />

  </Product>
</Wix>
globox
  • 29
  • 3
  • Well, that's not the design intent of Windows Installer but this might be similar to what Microsoft did with the old Fix It/Microsoft Easy Fix packages. WiX is intended to define and build every reasonable use of Windows Installer—so there is some hope. [Here's one](https://support.microsoft.com/en-us/help/3140245/update-to-enable-tls-1-1-and-tls-1-2-as-default-secure-protocols-in-wi). – Tom Blodget Dec 07 '18 at 00:45
  • IMO Windows Installer / WiX is the wrong tool for the job. The time you need for fighting against MSI / WiX would be better spend by adapting one of the many self-extractors out there, some even open source. [7-zip](https://www.7-zip.org/)'s SFX comes to mind and possibly [AutoIt](https://www.autoitscript.com). – zett42 Dec 07 '18 at 13:24

1 Answers1

2

Don't: No offence (seriously), but I absolutely, positively would not do this. In my opinion this is using a hammer as as screwdriver - at best. MSI is not suited for this purpose. As I always say: don't fight MSI, it fights back. You will be sorry :-).

I would say that with this approach you get a COM-structured storage file (MSI) which is now a bleak ZIP file-equivalent - less-capable and less compatible than a real ZIP-file now that it features no registration capabilities.

I don't like the tools, but you could use a regular zip file or a self-extracting EXE of some other type? I just dumped some links in here (in a hurry):


Administrative Installation: Simple extraction of files from an MSI is already available with Windows Installer's built-in Administrative Installation feature (and an alternative link: Extract MSI from EXE). Administrative installation is a built-in feature for every MSI file (unless actively blocked).

An administrative installation is in all essence a file extract. Its main purpose is to create a network installation point from which the installation can be run, but it amounts to a file extract and some modifications to the extracted MSI file itself (translation of the media table to use external source files). All source files will be uncompressed, making them easy to copy individually to the computer on demand.

Administrative Installation Command Line:

msiexec.exe /a MySetup.msi 

You could - in theory - use this approach (administrative installation) to allow a file extract for your MSI with no other changes done to the system.

I would suggest you just use a zip file. Or some other deployment technology: How to create windows installer. MSIX is effectively a new Zip-based deployment technology for Windows apps.

Got to run, hope you get some ideas.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • If I cannot find a way to prevent the folder registry entries, I will obviously have to look at alternatives. I nevertheless still think that it could be possible to create a "regfree" MSI installer. Or at least the Microsoft docs page I linked to in the question is suggesting that it can be done. So either the page is incomplete or plainly wrong. That's what I am trying to figure out. – globox Dec 10 '18 at 14:23
  • OK, I would say that with this approach defeats the purpose of an installer altogether. You get a COM-structured storage file (MSI) which is a bleak ZIP file-equivalent - a less-capable and less compatible ZIP-file essentially now that it features no registration capabilities. – Stein Åsmul Dec 10 '18 at 15:31