1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| '____________________Variables____________________
Dim Cle1,Cle2,Cle3,Cle4,Cle5,Cle6
Dim NumSerie
'_____________________________Liste des clés__________________________________
Cle1 = "XXXX"
Cle2 = "AAAA"
Cle3 = "BBBB"
Cle4 = "CCCC"
Cle5 = "YYYY"
Cle6 = "ZZZZ"
Sub checkUSB
strComputer = "."
On Error Resume Next
Set WshShell = CreateObject("Wscript.Shell")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDiskDrives = objWMIService.ExecQuery ("Select * from Win32_DiskDrive where interfacetype like 'USB'")
For each objDiskDrive in colDiskDrives
Numserie = objDiskDrive.PNPDeviceID
Next
intCount = 0
For Each objDiskDrive In colItems
If objDiskDrive.mediaType <> "" Then
intCount = intCount + 1
End If
Next
If intCount > 0 Then
if Numserie = Cle1 or Numserie = Cle2 or Numserie = Cle3 or Numserie = Cle4 or Numserie = Cle5 or Numserie = Cle6 then
Else
WshShell.run "cmd.exe /c C:\Users\dupont\Downloads\Removedrive.exe """ & Numserie & "",0,true
End if
End If
End Sub
Do
Call checkUSB ' Appelle a la procédure checkUSB
wscript.sleep 1000
loop |
Partager