简单U盘修复工具(SURT).hta

发布时间:2020-09-10编辑:脚本学堂
用hta编写的简单U盘修复工具

简单的U盘修复工具,可将U盘根目录下的文件、文件夹加上或去除“隐藏+系统+只读”属性,并具删除autorun.inf文件以避免病毒随磁盘的打开而自动运行的功能。

代码如下:
[vb.net] view plaincopy
   <html><head>     
    <title>简单u盘修复工具</title>     
    <style>     
    body,button {
    color:#666666;
    background-color:#cccccc; 
    font-size:16px;
    }  
    </style>     
    <HTA:APPLICATION
ID="Simple U-disk Repair Tool"
APPLICATIONNAME="Simple U-disk Repair Tool"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
ShowInTaskBar="yes"
MaximizeButton="no"
MinimizeButton="no"
SCROLL="no"
NAVIGABLE="yes"
BORDER="thin"
ICON="%SystemRoot%/system32/cleanmgr.exe"
    >      
    </head>     
    <SCRIPT Language="VBScript">     
    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>     
    <body>     
<h2 align="center">简单U盘修复工具(SURT)</h2>
(1/3)请选择需要操作可移动磁盘:     
<select size="1" name="DriveList">     
</select>
<br />     
(2/3)     
<input type="radio" name="RA_SHOW" value="0" checked>全部显示     
<input type="radio" name="RA_SHOW" value="7">全部隐藏     
<br />     
(3/3)     
<input type="checkbox" name="CB_DELAUTO" value="1" checked>删除"autorun.inf"文件     
<br />     
<p align="center">     
<button onClick="RunScript" accesskey=O>确定(<u>O</u>)</button>     
<button onClick="self.close()" accesskey=Q>退出(<u>Q</u>)</button>     
<br />© <a href="mailto:tunhsiaATgmail.com">Tunhsia</a>     
</p></body></html>