?
Solved

VBScript Shell.Application Delete File

Posted on 2011-05-11
6
Medium Priority
?
1,608 Views
Last Modified: 2012-06-21
Good morning,

Is it possible to use the Shell.Application object to delete a file? I am trying the delete a font from C:\Windows\Fonts using Scripting.FileSystemObject but even though it has been removed the file is shown until the machine is rebooted. I am hoping that by deleting the file using Shell.Application (which is used to install the Font) it will be successfully removed without the requirement for a reboot.

Thanks,

Michael
0
Comment
Question by:Barnardos_2LS
  • 3
  • 3
6 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 35736641
Hi, as shown here:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24175018.html

you need to remove the associated registry entry as well, but it requires knowing the full font name.

Regards,

Rob.
0
 
LVL 1

Author Comment

by:Barnardos_2LS
ID: 35736659
The registry entries were removed however the font files are still present (see attached image). These disappear when the machine is rebooted.
Fonts.bmp
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 35743436
Which OS are you on?  It works on Windows XP if you refresh the Fonts folder.  Do you have any programs open that might reference the install fonts?

Regards,

Rob.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:Barnardos_2LS
ID: 35744617
The OS is Windows XP SP3. The fonts show as TrueType instead of OpenType when the screen is refreshed and then following a reboot the files are removed. No programs are open which could be referencing the fonts. Is it possible to use the Shell.Application object to delete a file as this may be another option as deleting them manually in Explorer works first time?
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 35751535
In the registry, under HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts\ is there any other reference to a font of a similar name (like a TrueType version) that we might need to get rid of as well?  On my Windows XP SP3 machine when I remove a TrueType font, it disappears.

The Shell.Application object does have any method to delete a file.

I have read that if you run
net stop wmiapsrv
and
net start wmiapsrv
after deleting a font, it can refresh the list, but I'm not sure.

A little more research provided this:
http://msdn.microsoft.com/en-us/library/dd144833(v=vs.85).aspx

which states you need to make an API call to SendMessage to send a WM_FontChange notification to the system.  Unfortunately, this is not possible in VBScript.

Regards,

Rob.
0
 
LVL 1

Author Closing Comment

by:Barnardos_2LS
ID: 35775332
Thanks for your help.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Loops Section Overview
Suggested Courses
Course of the Month15 days, 5 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question