Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1722658
  • 博文数量: 234
  • 博客积分: 4966
  • 博客等级: 上校
  • 技术积分: 3322
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-13 01:03
文章分类

全部博文(234)

文章存档

2017年(2)

2016年(1)

2015年(8)

2014年(11)

2013年(44)

2012年(27)

2011年(22)

2010年(30)

2009年(37)

2008年(6)

2007年(45)

2006年(1)

分类: WINDOWS

2012-09-06 09:31:05



删除本地所有PPT格式的文件

点击(此处)折叠或打开

  1. ' *****************************************************************************
  2. ' TEST SCRIPT - Del Local All PPT File.vbs
  3. ' *****************************************************************************
  4. ' 作用: 删除本地所有的PPT文档
  5. ' 作者: Edward
  6. ' 日期: 2012.9.5 23:00
  7. ' Copyright (c) sunwill
  8. ' *****************************************************************************

  9. On ERROR RESUME NEXT

  10. Dim fso,file
  11. strComputer = "."

  12. '断开本地电脑所有网络驱动器
  13. Set objNet = CreateObject ("Wscript.Network")
  14. Set objNetdrv = objNet.EnumNetworkDrives
  15. For i = 0 To objNetdrv.Count -1 Step 2
  16. objNet.RemoveNetworkDrive objNetdrv.Item(i),True,True
  17. Next

  18. '结束所有PPT进程
  19. Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
  20. Set colProcessList=objWMIService.ExecQuery ("select * from Win32_Process where Name='powerpnt.exe' ")
  21. For Each objProcess in colProcessList
  22. objProcess.Terminate()
  23. Next

  24. '删除指定格式PPT的文件并记录日志
  25. Set objComputer = CreateObject("Shell.LocalMachine")
  26. Set fso = CreateObject("Scripting.FileSystemObject")
  27. Set file = fso.CreateTextFile("\\10.1.10.11\tmp\delppt\" & objComputer.MachineName & ".txt")
  28. Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  29. Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where Extension = 'ppt'")
  30. For Each objFile in colFiles
  31. Wscript.Echo objFile.Name
  32. file.WriteLine (objFile.Name)
  33. fso.DeleteFile (objFile.Name)
  34. Next


阅读(1105) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~