被流氓软件困扰? 连del命令都删不了,显示拒绝访问?那就试试这个程序吧!(必须管理员执行!只能保存再桌面,自己命名只能命名为Smasher.vbs)如果不想自己操作可以直接下载上面的exe软件
vbscript
Option Explicit
' ==============================================================================
' Shredder.vbs - Stubborn File/Folder Remover
' Description: Forces deletion of files/folders by taking ownership and
' resetting ACLs via PowerShell/CMD.
' Language: VBScript
' ==============================================================================
Dim objShell, objFSO, strPath, strCommand, intResult
Dim bIsAdmin
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Check if running as Administrator
bIsAdmin = IsAdmin()
If Not bIsAdmin Then
MsgBox "Error: This script requires Administrator privileges." & vbCrLf & _
"Please right-click the script and select 'Run as administrator'.", _
vbCritical, "Permission Denied"
WScript.Quit 1
End If
' Main Input Loop
Do
strPath = InputBox("Enter the full path of the file or folder to shred:" & vbCrLf & _
"(Example: C:\Windows.old or D:\Malware.exe)", _
"Stubborn File Shredder", "")
' Exit if user cancels or enters empty string
If strPath = "" Then
If MsgBox("Do you want to exit?", vbYesNo + vbQuestion, "Confirm Exit") = vbYes Then
WScript.Quit 0
End If
Else
Exit Do
End If
Loop
' Validate Path Existence
If Not objFSO.FileExists(strPath) And Not objFSO.FolderExists(strPath) Then
MsgBox "The specified path does not exist:" & vbCrLf & strPath, vbExclamation, "Invalid Path"
WScript.Quit 1
End If
' Confirm Deletion
intResult = MsgBox("WARNING: This action is irreversible!" & vbCrLf & vbCrLf & _
"Target: " & strPath & vbCrLf & vbCrLf & _
"The script will force take ownership and delete this item." & vbCrLf & _
"Are you sure you want to proceed?", _
vbYesNo + vbCritical, "Final Confirmation")
If intResult = vbNo Then
WScript.Quit 0
End If
' Execute Shredding Process
Call ShredPath(strPath)
MsgBox "Operation Completed.", vbInformation, "Success"
' ==============================================================================
' Subroutine: ShredPath
' Takes ownership, grants full control, and deletes the target.
' ==============================================================================
Sub ShredPath(ByVal targetPath)
Dim cmdTakeOwn, cmdIcacls, cmdDelete
Dim execResult
' Wrap path in quotes to handle spaces
targetPath = """" & targetPath & """"
' Step 1: Take Ownership (Recursive for folders)
' /F: File/Folder, /R: Recursive, /A: Give to Administrators group
cmdTakeOwn = "cmd.exe /c takeown /F " & targetPath & " /R /A /D Y"
' Step 2: Grant Full Control to Administrators
' /grant: Grant permission, (OI)(CI): Object/Container Inherit, F: Full Control, /T: Recursive
cmdIcacls = "cmd.exe /c icacls " & targetPath & " /grant Administrators:(OI)(CI)F /T"
' Step 3: Delete
' Check if it's a file or folder to choose the right command
If objFSO.FolderExists(Replace(targetPath, """", "")) Then
' Remove Directory /S (all subdirs) /Q (quiet)
cmdDelete = "cmd.exe /c rd /S /Q " & targetPath
Else
' Delete File /F (force read-only) /Q (quiet)
cmdDelete = "cmd.exe /c del /F /Q " & targetPath
End If
' Execute Commands with Hidden Window (0) and Wait (True)
On Error Resume Next
' Run Take Ownership
execResult = objShell.Run(cmdTakeOwn, 0, True)
' Run Icacls
execResult = objShell.Run(cmdIcacls, 0, True)
' Run Delete
execResult = objShell.Run(cmdDelete, 0, True)
If Err.Number <> 0 Then
MsgBox "An error occurred during the process:" & vbCrLf & Err.Description, vbCritical, "Error"
Err.Clear
End If
On Error GoTo 0
End Sub
' ==============================================================================
' Function: IsAdmin
' Checks if the current script is running with elevated privileges.
' ==============================================================================
Function IsAdmin()
Dim objNetwork, strComputer, colItems, objItem
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
' Try to access a protected WMI class or check SID
' A simpler method for VBS is checking if we can write to a system dir or using Shell.Application
Dim objShellApp
Set objShellApp = CreateObject("Shell.Application")
' This method checks if the current process has admin rights by attempting a silent elevation check
' However, the most reliable way in VBS without external tools is often just trying to run a privileged command
' Here we use a common trick: checking if we can access the Admin share or similar,
' but let's use the standard "whoami /groups" approach via shell execution for robustness.
Dim objExec, strOutput
Set objExec = objShell.Exec("cmd.exe /c whoami /groups")
strOutput = objExec.StdOut.ReadAll
If InStr(strOutput, "S-1-16-12288") > 0 Or InStr(strOutput, "S-1-16-16384") > 0 Then
IsAdmin = True
Else
IsAdmin = False
End If
End Function
如何操作使用
由于 VBScript 无法像 exe 那样直接右键"以管理员身份运行",你需要通过以下步骤正确执行该脚本:
第一步:保存脚本
- 新建一个文本文档。
- 将完整的代码粘贴进去
- 将文件另存为
Shredder.vbs(确保后缀名是.vbs而不是.txt,编码必须ANSI)。
第二步:不能直接运行!
需要再cmd里运行以下代码即可:powershell -Command "Start-Process 'wscript.exe' -ArgumentList '\"%USERPROFILE%\Desktop\Smasher.vbs\"' -Verb RunAs"
麻烦各位评论点赞加关注,谢谢!