Link to home
Start Free TrialLog in
Avatar of cantoris
cantorisFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Can't delete TTF files

I've written a (VB) script that when deployed via SCCM silently deletes an old program off a PC that is not being used anymore.  On most PCs this works fine, but on a small proportion of PCs, this fails to delete some TTF font files that are stored in a subfolder of the programme's installation folder in Program Files.
eg  C:\Program Files\Supplier\AppName\Fonts

If I try and delete them manually through the GUI it acts as though they're in use and if I try it from a command prompt I get an Access Denied.  Effective Permissions shows I have full control and from a command prompt I CAN /rename/ them or /move/ them to a different folder but not delete them!  The files only have the +A attribute.  I can't run Handle against the PC (remotely) as it would pop up the EULA box.  I suspect it will merely show them locked by Explorer.

My uninstalling script uses the FileSystemObject to recursively delete the app folder like this:
Sub DeleteFolder(ByVal strFolder)
 a) Bind to strFolder using the FSO
 b) Enumerate subfolders
 c) For Each subfolder, Call the Sub again specifying the subfolder path
 d) Use the folder's Files collection to enumerate and then [force] delete all files in the folder
 e) Delete the now empty folder
End Sub

Has anyone seen this phenomenon before?  (Windows XP)
After a bit of Googling I found someone else who'd seen something similar having dropped a TTF file to their desktop.  No obvious reason though and I don't know why it only sometimes happens.
Avatar of cantoris
cantoris
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Having just submitted that, I've discovered the fonts listed here:
HKLM\Software\Microsoft\WindowsNT\CurrentVersion\Fonts
There's a load of String values where the name is the font name and the value is the full path to the TTF file within the app's folder.

If I delete them from the registry, I still can't delete the font files.  Perhaps after a reboot they'd be deleteable.  Is there a formal way of unregistering a font?
ASKER CERTIFIED SOLUTION
Avatar of the_endjinn
the_endjinn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, just seen your comment.

Yes, try a reboot after removing the registry entry, the font will already be loaded and I'm not aware of a way to unload it without the reboot.
Thanks :)

I'm wondering about using PendingFileRenameOperations to handle the deletion on the next reboot since I want it to be silent and automatic.
I know that this key is a multistring key and that the second of each pair of strings needs to be null.
How can I write this in using the SetMultiStringValue value of the WMI StdRegProvider?

I know I'd give it an array as a parameter, so for array index 0 I'd have a string like
"\??\C:\Program Files\Supplier\Appname\Fonts\font.ttf"  (but without quotes)
and then for array index 1 would I set it to Chr(0) ?
and then array index 2 would be the next file and so on.

There's also the question of the containing folders.  After deleting the CurrentControlSet font registry keys and rebooting, none of the folder tree should be locked so can I just put the uppermost parent folder name (and null) in as a single pair in the Pending key and ignore the individual files?
ie  "\??\C:\Program Files\Appname" - with or without a trailing "\"?

Thanks for any help.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm stripping the relevant font values from the registry then trying to delete the files and any that fail I'm adding into the Pending key using a subroutine I've now written.