Инструменты пользователя

Инструменты сайта


Боковая панель

Навигация

unix
notes
firmware
windows
Говнокод

Внешние ссылки

Внешняя ссылка

usb_cleaner_vbs

USB cleaner VBS

title
Wscript.Echo "USB cleaner Запущен"
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set objEvents = objWMIService.ExecNotificationQuery ("SELECT * FROM __InstanceCreationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_LogicalDisk' AND TargetInstance.DriveType = 2")
Set objFS = CreateObject("Scripting.FileSystemObject")
Do
    Set objReceivedEvent = objEvents.NextEvent
    strPath = objFS.BuildPath(objReceivedEvent.TargetInstance.Caption, "\")
    If objFS.FolderExists(strPath) Then
        On Error Resume Next
        Set objFolder = objFS.GetFolder(strPath)
        If Err.Number = 0 Then
            For Each objItem In objFolder.SubFolders
                If objItem.Attributes And 2 Then objItem.Attributes = objItem.Attributes - 2
                If Err.Number <> 0 Then Err.Clear
            Next
            For Each objItem In objFolder.Files
                If objItem.Attributes And 2 Then objItem.Attributes = objItem.Attributes - 2
                If Err.Number <> 0 Then Err.Clear
            Next
			For Each File in objFolder.Files
				If LCase(objFS.GetExtensionName(File)) = "lnk" Then
				File.Delete true
			End If
			Next
			For Each File in objFolder.Files
				If LCase(objFS.GetExtensionName(File)) = "nil" Then
				File.Delete true
			End If
			Next
			For Each File in objFolder.Files
				If LCase(objFS.GetExtensionName(File)) = "inf" Then
				File.Delete true
			End If
			Next
			For Each File in objFolder.Files
				If LCase(objFS.GetFileName(File)) = "autorun.exe" Then
				File.Delete true
			End If
			Next
		 Else
            Err.Clear
        End If
        Set objItem = Nothing: Set objFolder = Nothing
    End If
    Wscript.Echo "USB флешка успешно очищена"
Loop
usb_cleaner_vbs.txt · Последнее изменение: 2018/02/17 16:08 — sector

Яндекс.Метрика