【发布时间】:2015-05-09 16:43:24
【问题描述】:
我想知道是否有办法使我的 vbs 脚本可以检查并删除名称中包含特定单词的任何文件。这是我目前所拥有的:
x=MsgBox ("Searching for any infected files...",64,"Search")
DIM filesys
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("C:\Documents and Settings\Name\Desktop\example.txt") Then
WScript.Sleep 1500
x=MsgBox ("Warning! A infected file was found!",48,"Warning")
filesys.DeleteFile "C:\Documents and Settings\Name\Desktop\example.txt"
x=MsgBox ("File was deleted!",48,"File Deleted")
WScript.Sleep 1000
x=MsgBox ("This Computer is now clean!",64,"Hooray!")
Else
WScript.Sleep 500
x=MsgBox ("File not found! This Computer is clean!",64,"Hooray!")
End If
还有没有办法让用户名/文件路径在任何计算机上都可以使用?我知道是
"C:\Documents and Settings\%username%\Desktop\example.txt"
批量,但是在 vbscript 中有类似的东西吗?是否还有一种方法可以删除名称中也包含“example”的任何扩展名的文件?例如:
filesys.DeleteFile "C:\Documents and Settings\Name\Desktop\example.anyextension"
非常感谢!我希望你不介意我的大量问题,我刚刚开始使用 VBS/VBScript 进行编码,非常感谢你的帮助! :)
【问题讨论】:
-
我猜你想写一个像清洁器这样的东西,所以你可以从中得到启发 ==> stackoverflow.com/questions/23832414/…
标签: batch-file vbscript