1

In my Product, I've defined a custom action that looks like this:

<CustomAction Id="InstallScreensaver" 
              Directory="SystemFolder"
              Return="asyncNoWait" 
              ExeCommand="rundll32.exe desk.cpl,InstallScreenSaver [#screensaver]"/>

following this blog post: https://ithoughthecamewithyou.com/post/wix-tricks-for-screen-savers

But when I link it (light) I get this error:

error LGHT0094 : Unresolved reference to symbol 'Directory:SystemFolder' in section 'Product:*'.

Why is that?

On Wix's documentation of predefined variables, I can SystemFolder:

SystemFolder - gets the well-known folder for CSIDL_SYSTEMX86 on 64-bit Windows and CSIDL_SYSTEM on 32-bit Windows.

and I also create a shortcut that uses that variable:

<Shortcut Id="Shrt_Install_Screensaver" 
          Name="Install Screensaver"
          WorkingDirectory="SystemFolder" Icon="icon.ico"
          Target="[SystemFolder]rundll32.exe"
          Arguments="desk.cpl,InstallScreenSaver [#screensaver]"/>
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622

1 Answers1

1

Maybe try to add SystemFolder directly underneath TARGETDIR as a first test (compiles and runs for me with a rushed mock-up):

<Directory Id="TARGETDIR" Name="SourceDir">

  <Directory Id="SystemFolder" />
  <...>
</Directory>

I think this is enough for the msiexec.exe engine to "fill in the rest", even if you don't specify a real folder name since this is one of the System Folder Properties.

I am not sure whether to call your link problem a WiX bug or not. It should probably be handled auto-magically since the folder in question is a system folder. I would go with calling it a bug or a missing piece of auto-magic.

Is your screen saver 64-bit or 32-bit? For the record System32 contains 64-bit files and SysWOW64 contains 32-bit files, but I guess you already knew that. Only in Windows...


Some links for safekeeping:

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • For now, my screensaver is 32 bit only. This did work but my concern is, can't TARGETDIR be mapped to a different drive letter than the one in which Windows is installed? – Pablo Fernandez Apr 13 '18 at 09:54
  • Good question. All the [System Folder Properties](http://msdn.microsoft.com/en-us/library/windows/desktop/aa370905%28v=vs.85%29.aspx#system_folder_properties) are reserved directory identifiers and they are resolved at runtime by appropriate WinAPI calls inside the Windows Installer Engine. I just tried to put SystemFolder under the ProgramFilesFolder directory element and it still resolved to the correct system folder. Perhaps candle should warn against this? I'll check the WiX issues database if this is a known issue. Also, [**about TARGETDIR**](https://stackoverflow.com/a/39401425/129130). – Stein Åsmul Apr 13 '18 at 12:02
  • Historically, the WiX Toolset will not add things to your MSI that it cannot model perfectly without data. In the case of the SystemFolder, it can be placed in many different places in the Directory tree to control the source organization. In WiX v4, this philosophy is changing and more will be done for you automagically. This feature is not implemented yet but I hope it will be along with hiding `TARGETDIR`/`SourceDir` completely. We'll see. – Rob Mensching Apr 15 '18 at 06:10