Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista Tutorial - Delete File VBS

Reply
 
Old 08-22-2008   #1 (permalink)
grumblenoise
Guest


 
 

Delete File VBS

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

My System SpecsSystem Spec
Old 08-22-2008   #2 (permalink)
Tom Lavedas
Guest


 
 

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
Old 08-22-2008   #3 (permalink)
grumblenoise
Guest


 
 

Re: Delete File VBS

Thank you Tom.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
cannot delete a file due to error that file is open Vista file management
cannot delete old DOS file Vista file management
cannot delete mail in delete file Vista mail
Create New folder, move file, delete file. Explorer Freeze General Discussion
Re: YOU CANT DELETE A FILE? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46