• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 720
  • Last Modified:

Suppress message from Windows Script Host vbs script

I use this vbs script below to auto delete NT backups. After each delete it displays a message Deleting "v:\path\filename" How to suppress these messages? See pic embedded

'--------------------------------------------
'This script will delete .bkf files that were
'created "MaxAge" days ago.
'30.1.2009 FNL
'--------------------------------------------
Active = true
sSource = "V:\DailyBackup\SystemStates"
iMaxAge = 6 'days

Checked = 0
Deleted = 0

Set oFSO = CreateObject("Scripting.FileSystemObject")
if active then verb = "Deleting """ Else verb = "Old file: """
CheckFolder oFSO.GetFolder(sSource)

WScript.echo
if Active then verb = " file(s) deleted" else verb = " file(s) would be deleted"
wscript.echo Checked & " file(s) checked, " & Deleted & verb

Sub CheckFolder (oFldr)
For Each oFile In oFldr.Files
if ucase(right(oFile.name, 4)) = ".BKF" then
Checked = Checked + 1
If DateDiff("D", oFile.DateLastModified, Now()) > iMaxAge Then
Deleted = Deleted + 1
WScript.Echo verb & oFile.Path & """"
If Active Then oFile.Delete
End If
end if
Next
End Sub vbs message
0
yohayon
Asked:
yohayon
  • 3
1 Solution
 
jawa29Commented:
You just need to remove the Wscript.echo's

Jawa29
0
 
jawa29Commented:
I have bolded the lines to remove below.

'--------------------------------------------
'This script will delete .bkf files that were
'created "MaxAge" days ago.
'30.1.2009 FNL
'--------------------------------------------
Active = true
sSource = "V:\DailyBackup\SystemStates"
iMaxAge = 6 'days

Checked = 0
Deleted = 0

Set oFSO = CreateObject("Scripting.FileSystemObject")
if active then verb = "Deleting """ Else verb = "Old file: """
CheckFolder oFSO.GetFolder(sSource)

WScript.echo
if Active then verb = " file(s) deleted" else verb = " file(s) would be deleted"
wscript.echo Checked & " file(s) checked, " & Deleted & verb

Sub CheckFolder (oFldr)
For Each oFile In oFldr.Files
if ucase(right(oFile.name, 4)) = ".BKF" then
Checked = Checked + 1
If DateDiff("D", oFile.DateLastModified, Now()) > iMaxAge Then
Deleted = Deleted + 1
WScript.Echo verb & oFile.Path & """"
If Active Then oFile.Delete
End If
end if
Next
End Sub

Jawa29
0
 
yohayonAuthor Commented:
Can I just insert rem or #?
0
 
jawa29Commented:
To comment out a VBS line you use '

Jawa29
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now