Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbs to delete certain file types

Status
Not open for further replies.

kss1133

Programmer
Mar 22, 2006
22
US
I have this vbs file that I have setup on a job to run at 2am.

DeleteFile "c:\test\*.txt"

function DeleteFile(WhatFile)
on Error Resume Next
dim fso
set fso=createobject("Scripting.Filesystemobject")
fso.DeleteFile(WhatFile)
End Function

I want to be able to set this up so I can pass the folder and file path into it.
Can someone help me out, I have tried many variations but I think I am setting the job wrong.

Thanks.
 
Have a look at the WScript.Arguments collection

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
If Wscript.Arugments.Count = 1 Then
strPassed = Wscript.Argument.Item(0)
End If

'i prefer the named arguments
'get the source file
If Wscript.Arguments.Named.Exists("source") Then
strSourceFile = WshShell.ExpandEnvironmentStrings(Wscript.Arguments.Named.Item("source"))
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top