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.
LVL 16
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cantorisAuthor Commented:
Having just submitted that, I've discovered the fonts listed here:
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?
Sounds like the fonts are registered with Windows, might not allow you to delete them directly if this is the case. I recommend having your script remove the font from the registry whenever it encounters a TTF file.

Fonts are under "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\FontName" so you will need to delete this key first and then you should be able to delete the TTF file.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day 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.
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

cantorisAuthor Commented:
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.
cantorisAuthor Commented:
OK I've found the answer to how to use PendingFileRenameOperations after a lot of experimenting!

Passing SetMultiStringValue an Array("\??\C:\Program Files\Supplier\Application\File", Chr(0))  works perfectly!
But it doesn't appear to work for a folder unless it's empty.
It does work though if I pass it a multistring containing all the folder contents in order followed by paths and parent paths - working my way back up the tree so it can delete them in order - this should be easy to add to my recursive script since that's the order the deletion attempts anyway.

Any suggestions for easier ways to do this, or better still, any ideas as to what would be the official technique for this whole issue?
cantorisAuthor Commented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows XP

From novice to tech pro — start learning today.