Thread: Delete File VBS
View Single Post
Old 08-22-2008   #2 (permalink)
Tom Lavedas


 
 

Re: Delete File VBS

On Aug 22, 7:58 am, grumbleno...@xxxxxx wrote:
Quote:

> Hi Guys,
>
> Quite a simple one, I need to delete a file from our users computers,
> I want to use a VBS script which I will run at logon. If file does
> not exist the VBS script should not run and if it does it should be
> deleted. It needs to be silent as well.
>
> Cheers
From the WSH VBS help documentation ...

on error resume next
sFileSpec = "C:\somefolder\somewhere\somefile.ext"
DeleteAFile(sFileSpec)

Sub DeleteAFile(filespec)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(filespec)) Then fso.DeleteFile(filespec)
End Sub

WSH 5.6 documentation download (URL all one line)
http://www.microsoft.com/downloads/d...displaylang=en

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
My System SpecsSystem Spec