为何运行VBS脚本提示没有权限

来源:百度知道 编辑:UC知道 时间:2024/05/26 10:55:31
以下是我写的程序代码:请帮我看看是不是那儿写错了。为什么在运行的时候提示的是第7行第一字符错误,错误提示是没有权限。
Set WshShell=WScript.CreateObject("WScript.Shell")
Dim fso,d,dc
Set fso=CreateObject("Scripting.FileSystemObject")
Set dc=fso.Drives
For Each d in dc
If d.DriveType=2 Then
return=WshShell.Run("defrag"& d &"-f",1,TRUE)
End If
Next
Set WshShell=Nothing

Set WshShell=WScript.CreateObject("WScript.Shell")
Dim fso,d,dc
Set fso=CreateObject("Scripting.FileSystemObject")
Set dc=fso.Drives
For Each d in dc
If d.DriveType=2 Then
WshShell.Run "cmd /c defrag " & d &"-f"
End If
Next
Set WshShell=Nothing

看看这样可不可以