VBS打造自己的重启删除工具
Posted onVBS打造自己的重启删除工具
安装文件(REG),Install.reg,双击导入即可完成安装 1
Windows Registry Editor Version 5.00
2
3
[HKEY_CLASSES_ROOT\/*\shell\重启删除\
command
]
4
@=
"WScript.exe //nologo c:\windows\system32\rerase.vbs \"%1\""
rerase.vbs,需拷贝至c:\windows\system32\rerase.vbs ,当然也可是其它目录,但是要修改Insatll.reg 01
On Error Resume Next
02
TargetFile = Wscript.Arguments(0) 03
04
Set ObjRUN = Wscript.createObject(
"Wscript.shell"
) 05
Set ObjFSO = CreateObject(
"Scripting.FileSystemObject"
)
06
07
If ObjFSO.FileExists(TargetFile) Then
08
09
Set GetFile = ObjFSO.GetFile(TargetFile)
10
Set InfFile = ObjFSO.CreateTextFile(objFSO.GetParentFolderName(GetFile) &
"\INFFILE.INF"
) 11
12
InfFile.WriteLine(
"[Version]"
) 13
InfFile.WriteLine(
"Signature = "
"$Chicago$"
""
)
14
InfFile.WriteLine(
"[DestinationDirs]"
) 15
InfFile.WriteLine(
"DefaultDestDir = 01"
)
16
InfFile.WriteLine(
"[DefaultInstall]"
) 17
InfFile.WriteLine(
"DelFiles = DELETELIST"
)
18
InfFile.WriteLine(
"[DELETELIST]"
) 19
InfFile.WriteLine(
"INFFILE.INF"
)
20
InfFile.WriteLine(ObjFSO.GetFileName(GetFile) &
",,,1"
) 21
InfFile.Close
22
23
ObjRUN.Run
"RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 128 "
& objFSO.GetParentFolderName(GetFile) &
".\INFFILE.INF"
, 0, TRUE
24
25
WScript.Sleep 200
26
27
If ObjFSO.FileExists(TargetFile) Then
28
Return = Msgbox(
"必须重启才能完成删除操作,你想现在重启吗?"
, vbYesNo + vbInformation + vbDefaultButton2,
"提示"
) 29
IF Return = vbYes Then
30
ObjRUN.Run
"shutdown -r -t 0" 31
End If
32
End If 33
34
Else 35
MsgBox
"文件未找到!"
, 16,
"错误"
36
End If
来源: [http://my.oschina.net/veterans/blog/27839](http://my.oschina.net/veterans/blog/27839)