如何用VBS删除指定文件

来源:百度知道 编辑:UC知道 时间:2024/05/18 00:18:02
比如我要删除%windir%\system32\test.inf(是否可用%windir%?)

该怎么写VBS角本?
请详细写出来,我对VBS点都不了解!

谢谢

--------------------
这是我在网上下的,也可以在这里修改。
Dim oFSO,f1,WSH
SET WSH=WSCRIPT.CreateObject("WSCRIPT.SHELL")
WSH.POPUP("确定要清除?")
On Error Resume Next
Set oFSO=CreateObject("Scripting.FileSystemObject")
Set f1=fso.GetFile("%windir%\system32\test.inf")
f1.del
Set oFSO=Nothing
WSH.POPUP("请重启机器!")

只要测试通过,马上给分!
zhb0813,用你的方法运行不起啊!!

在你那里测试通过了吗?

运行VBS文件有其它条件吗?

第一次修改:
Dim oFSO,f1,WSH
SET WSH=WSCRIPT.CreateObject("WSCRIPT.SHELL")
WSH.POPUP("确定要清除?")
On Error Resume Next
Set oFSO=CreateObject("Scripting.FileSystemObject")
Set f1=ofso.GetFile("c:\windows\system32\test.inf")
oFSO.DeleteFile f1
Set oFSO=Nothing
WSH.POPUP("请重启机器!")

~~~~~~~~~~~~~~
第二次修改
Dim oFSO,f1,WSH
SET WSH=WSCRIPT.CreateObject("WSCRIPT.SHELL")
WSH.POPUP("确定要清除?")
On Error Resume Next
Set oFSO=CreateObject("Scripting.FileSystemObject")
oFSO.DeleteFile("c:\windows\system32\test.inf")
Set oFSO=Nothing
WSH.POPUP("请重启机器!")

+++++++++++++++++++++++++++++++++++++++++++++++++++++++
测试成功。。。

Set fso=CreateObject("Scripting.FileSystemObject")
Set f1=fso.GetFile("c:\windows\system32\test.inf")
v=msgbox(