This article showed me how to install fonts from a script, but now I’m faced with the problem of removing them. How can I do that ? Any language is ok, I’ll convert the info to what I need later.
EDIT: Okay, so I now know how to uninstall fonts ( most of the part at least ). I’m issuing calls to RemoveFontResource. After that I use SendMessage with parameters: 0xffff,0x001D,0,0 ( HWND_BROACAST,WM_FONTCHANGE … and I forgot what the other two parameters stand for ). The thing is, this deletes the font, but in the Control Panel‘s Fonts entry, the font still appears there ( even though if you try to delete it from there as well, it will say it cannot read from source file or disk.
So basically, I’m deleting a font in this order:
- deleting physically from the
C:\Windows\Fonts - calling RemoveFontResource
- calling SendMessage
What’s the proper way of uninstalling?
From all the documentation I’ve ever seen those three lines of code are the “proper” way to do it but as we well know it doesn’t quite work – as expected.
REBOOT
I executed the code above and duplicated your problem (control panel still shows the font, however the font file is gone). I then rebooted. Now the font is gone from the Fonts Control Panel applet.
Something else to note: even though control panel still showed the font as “there” applications no longer listed it in their font lists (I specifically tried Wordpad, before and after deleting webdings.ttf – without rebooting)
Yea i know – rebooting is a poor solution – especially if you need to update the Font since you can’t reinstall it (via the control panel anyways – it claims the font is still installed) until you reboot after removing it (I tried).
However if all you want to do is remove the font – its not the worst solution – the font is essentially gone after you uninstall it (apps don’t see it, its only visible in control panel fonts as far as i can tell) and you wouldn’t need to force a reboot.
From the SDK help on RemoveFontResourceFont (which may indicate why the oddness is seen)