1

I have build a setup via WIX that installs the font HKGrotesk on the C:/windows/fonts folder. When I execute the setup all is fine and the font is installed.

<Directory Id="..." Name="HK">
  <Component Id="..." Guid="...">
    <File Id="..." Source="(...)\fonts\HK\HKGrotesk-Black.otf" TrueType="yes" />
  </Component>
</DirectoryRef>

The problem is when I try to delete the installation files. I get a message that says that my HKGrotesk-Black.otf is open in System.

How can I have my installation working and be able to delete the font file from my installation files folder?

Littack
  • 23
  • 3
  • Did you close down all apps using the font before uninstall? Perhaps [try to use the scripts here](https://stackoverflow.com/a/46918276/129130) to test uninstall manually? (unless you do so already). – Stein Åsmul Oct 19 '20 at 20:27
  • That's it! Thank you so much! – Littack Oct 27 '20 at 21:01
  • What exactly was it that worked? – Stein Åsmul Oct 27 '20 at 22:32
  • The script. This explanation [here](https://stackoverflow.com/a/46918276/129130) is really accurate. I used the script to install the fonts via VBScript like it is being installed via windows. The problem is that the path of the windows registry was pointing directly to the fonts files generated by my msi setup. So I was not able to delete the installed files because windows said "That font files are mine". Using the script it was a copy of the fonts files that were installed. – Littack Nov 02 '20 at 11:10
  • OK, I added an answer below quickly. In case it helps someone (and to have this written for a future where my goldfish memory has forgotten it). – Stein Åsmul Nov 02 '20 at 11:50

1 Answers1

1

Original: The below condensed from this answer as source.


Font Table: The Font table in an MSI is used to install fonts properly. In WiX you just specify a few attributes as explained here:

<DirectoryRef Id="FontsFolder">
  <Component Id="MyFontsFonts" Guid="...">
    <File Id="font1.ttf" Source="font1.ttf" TrueType="yes" />
  </Component>
</DirectoryRef>

Windows Explorer: You can register a font by copying it into the Fonts folder via Windows Explorer. The shell will register the font (at least it did in downstream OS versions). Google Fonts (try it with the Google font: Nosifer - very recognizable).


Script: You can use VBScript to register a font:

Set sa = CreateObject("Shell.Application")
Set fonts  = sa.NameSpace(20)
fonts.CopyHere "C:\tmp\SomeFont.ttf"

in PowerShell (hex 0x14 = 20 dec):

$sa =  new-object -comobject shell.application
$Fonts =  $sa.NameSpace(0x14)
$Fonts.CopyHere ("C:\tmp\SomeFont.ttf")

Silly scripts with absolute paths and other defects, but they should work as samples.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164