Sign in to follow this  
Followers 0
Xtort

Font Deletion

4 posts in this topic

#1 ·  Posted (edited)

Hello all,

I'm new to this forum and fairly new to scripting in general, so try to go easy on me. I have been trying to create a script to uninstall the basic Goudy fonts from certain machines running WinXP. Searching through this forum turned up some interesting finds in dealing with fonts but nothing seemed to point to a solution for this function. Scripting font installs seems to be simply using FileCopy to move them to the font folder. I haven't yet found an easy way to remove a font from the same folder with out leaving bits of it behind.

I'm new enough to AutoIt that the enormous chunks of code found in scripts such as Yashied's FontViewer (awesome btw) make my head spin. Although I did use the well placed search feature I did not turn up answers that a newb like myself could decipher.

This seems to make the most sense so far, but I must not be understanding a the functions in this line because it doesn't seem to do anything.

DllCall('gdi32.dll', 'int', 'RemoveFontResource', 'ptr*', 'GOUDYSTO.TTF')
Edited by Xtort

Share this post


Link to post
Share on other sites



Just use FileDelete(). Windows will do everything himself.

EDIT:

Welcome to the forum.

Well I feel like the biggest 'ijiot' in history right about now. I had tried that before but did not reboot before checking the results. If you don't reboot the file attributes are left behind to be seen.

Somehow MS Word 2003 can still access and then repair/replace the standard Goudy fonts after using FileDelete(). The simple action of clicking on the font and selecting delete works perfectly, but performing the same function via a script is a tad more challenging at my skill level. **Shakes fist at MS**

Share this post


Link to post
Share on other sites

Well I feel like the biggest 'ijiot' in history right about now. I had tried that before but did not reboot before checking the results. If you don't reboot the file attributes are left behind to be seen.

Somehow MS Word 2003 can still access and then repair/replace the standard Goudy fonts after using FileDelete(). The simple action of clicking on the font and selecting delete works perfectly, but performing the same function via a script is a tad more challenging at my skill level. **Shakes fist at MS**

You can not delete a file (font) while it is being used by another application (Microsoft Office). But you can delay deleting until the next start of system.

#Include <WinAPIEx.au3>

Global Const $MOVEFILE_DELAY_UNTIL_REBOOT = 0x04

Global $sFont = _WinAPI_ShellGetSpecialFolderPath($CSIDL_FONTS) & '\GOUDYSTO.TTF'

Do
Until Not _WinAPI_RemoveFontResource($sFont, 1)

If Not FileDelete($sFont) Then
    $Ret = DllCall('kernel32.dll', 'int', 'MoveFileExW', 'wstr', $sFont, 'ptr', 0, 'dword', $MOVEFILE_DELAY_UNTIL_REBOOT)
    MsgBox(0, '', $Ret[0])
EndIf

WinAPIEx.au3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0