请问一个电脑方面的东西.VBS文件类的

来源:百度知道 编辑:UC知道 时间:2024/09/23 15:30:59
Set WshShell=Wscript.CreateObject("Wscript.Shell")
Dim fso,d,dc
Set fso=CreateObject("Scripting.FileSystemObject")
Set dc=fso.Drives
For Each d in dc
lf d.DriveType=2Then
Return=WshShell.Run("defrag"&d&"_f",1,TRUE)
End lf
Next
Set WshShell=Nothing
我想做一个 磁盘碎片整理.VBS 脚本
可运行的时候说我的Microsoft VBScript 编辑器错误
这我都是照书上写的,可为什么是错的啊 有知道的说一下
虽然给不了你们重谢 但我还是给对的人10分吧

Set dc=CreateObject("Scripting.FileSystemObject").Drives
For Each d in dc
if d.DriveType=2 Then
CreateObject("Wscript.Shell").Run "defrag "&d&" -f",1,True
End if
Next

是IF,不是LF

另外帮你把脚本精简了一下

第六行和第八行是if,不是lf,你打错啦。