On Error Resume Next
window.resizeTo 360,230
ileft=(window.screen.width-360)/2
itop=(window.screen.height-230)/2
window.moveTo ileft,itop
'动态显示盘符
Sub Window_Onload
Dim fso, d, dc
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
Set objOption = Document.createElement("OPTION")
objOption.Text = d.DriveLetter & ":"
objOption.Value = d.DriveLetter & ":"
DriveList.Add(objOption)
Next
End Sub
Dim nAttr
'返回一个 Folder 对象,表示指定驱动器的根文件夹。
Function ShowRootFolder(drvspec)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetDrive(drvspec)
ShowRootFolder = f.RootFolder
End Function
'操作文件夹
Function ShowFolderList(folderspec,nAttr)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(ShowRootFolder(folderspec))
Set fc = f.SubFolders
For Each f1 in fc
f1.attributes=nAttr
Next
End Function
'操作文件
Function ShowFileList(folderspec,nAttr)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(ShowRootFolder(folderspec))
Set fc = f.Files
For Each f1 in fc
f1.attributes=nAttr
Next
End Function
Sub RunScript
If RA_SHOW(0).Checked Then
nAttr=RA_SHOW(0).value
ElseIf RA_SHOW(1).Checked Then
nAttr=RA_SHOW(1).value
End If
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(DriveList.Value)
If d.DriveType=1 Then
If CB_DELAUTO.Checked Then
If (fso.FileExists(d & "/autorun.inf")) Then
Set MyFile = fso.GetFile(d & "/autorun.inf") 'Delete file
MyFile.Delete(true)
End If
End If
Call ShowFolderList(d,nAttr)
Call ShowFileList(d,nAttr)
If vbOK=MsgBox ("操作成功!现在查看效果?",vbOKCancel+vbInformation,_
"Simple U-disk Repair Tool") Then
expldrv="Explorer.exe /e," & DriveList.Value
set ws=CreateObject("WScript.Shell")
ws.run expldrv
End If
Else
If vbYes=MsgBox ("此驱动器非可移动磁盘,如遇属性无法更改将出错!是否继续?",_
vbYesNo+vbQuestion,"Simple U-disk Repair Tool") Then
If CB_DELAUTO.Checked Then
If (fso.FileExists(d & "/autorun.inf")) Then
Set MyFile = fso.GetFile(d & "/autorun.inf") 'Delete file
MyFile.Delete(true)
End If
End If
Call ShowFolderList(d,nAttr)
Call ShowFileList(d,nAttr)
If vbOK=MsgBox ("操作成功!现在查看效果?",vbOKCancel+vbInformation,_
"Simple U-disk Repair Tool") Then
expldrv="Explorer.exe /e," & DriveList.Value
set ws=CreateObject("WScript.Shell")
ws.run expldrv
End If
End If
End If
End Sub
《SCRIPT》