Vbscript 已删除闪存驱动器中低于特定大小的exe文件

Vbscript 已删除闪存驱动器中低于特定大小的exe文件,vbscript,Vbscript,我有内森·赖斯的密码。这是可行的,但问题是: 我想要sDirectoryPath=“适用于任何闪存驱动器” '这里我们设置您的全局变量。这些价值观 '在脚本运行时不要更改。 Set of so=CreateObject(“Scripting.FileSystemObject”) sDirectoryPath=“j:\” 递归文件夹sDirectoryPath 子递归文件夹(sFolder) '这里我们设置oFolder对象,注意它是 '变量范围在此子项中,因此您可以 “设置多次,其值仅为 '当前

我有内森·赖斯的密码。这是可行的,但问题是:

我想要sDirectoryPath=“适用于任何闪存驱动器”

'这里我们设置您的全局变量。这些价值观
'在脚本运行时不要更改。
Set of so=CreateObject(“Scripting.FileSystemObject”)
sDirectoryPath=“j:\”
递归文件夹sDirectoryPath
子递归文件夹(sFolder)
'这里我们设置oFolder对象,注意它是
'变量范围在此子项中,因此您可以
“设置多次,其值仅为
'当前正在运行的sub的。
文件夹集=of so.GetFolder(sFolder)
“在这里,我们正在循环浏览数据库中的每个文件
'目录路径。
对于oFolder.Files中的每个文件
'这只是检查文件大小是否小于450Kb
如果oFile.Size<450000且正确(LCase(oFile.Name),则3)=“exe”
oFile.Delete True
如果结束
下一个
'这里我们做递归位。我们需要循环通过
'目录中的每个文件夹,并调用相同的
'sub以确保我们检查路径中的每个文件夹。
对于oFolder.SubFolders中的每个oFolder
文件夹路径的递归文件夹
下一个
端接头
'调用sub时,不需要设置它们的值
'转换为变量名,并且不使用括号。
Msgbox“小呼叫删除成功完成”
“清理
一组SO=零
'在这里,我们设置您的全局变量。这些价值观
'在脚本运行时不要更改。
Set of so=CreateObject(“Scripting.FileSystemObject”)
设置oWMIService=GetObject(“winmgmts:\\.\root\cimv2”)
'我们从WMI中选择可移动驱动器
Set oDrives=oWMIService.ExecQuery(_
“从Win32_LogicalDisk中选择*,其中DriveType=2”)
'在此处循环使用可用的驱动器
对于oDrive中的每个oDrive
RecurseFolders oDrive.DeviceID&“\”
下一个
"清理",
设置oDrives=Nothing
子递归文件夹(sFolder)
'这里我们设置oFolder对象,注意它是
'变量范围在此子项中,因此您可以
“设置多次,其值仅为
'当前正在运行的sub的。
文件夹集=of so.GetFolder(sFolder)
“在这里,我们正在循环浏览数据库中的每个文件
'目录路径。
对于oFolder.Files中的每个文件
'这只是检查文件大小是否小于450Kb
如果oFile.Size<450000且正确(LCase(oFile.Name),则3)=“exe”
oFile.Delete True
如果结束
下一个
'这里我们做递归位。我们需要循环通过
'目录中的每个文件夹,并调用相同的
'sub以确保我们检查路径中的每个文件夹。
对于oFolder.SubFolders中的每个oFolder
文件夹路径的递归文件夹
下一个
端接头
'调用sub时,不需要设置它们的值
'转换为变量名,并且不使用括号。
Msgbox“小呼叫删除成功完成”
“清理
一组SO=零

>我想要sDirectoryPath=“任何闪存驱动器”谁是Nathan Rice?羽毛球运动员?或者?可以使用闪存g:h:j:k:l:。。。。。。。。。。。。。每次改变,所以我去脚本检测到USB驱动器自动或使用如果存在g:(do对象)deletle布拉赫布拉赫如果存在我:(do对象)deletle布拉赫布拉赫如果存在h:(do对象)deletle布拉赫布拉赫Nathan Rice有人帮我得到这个代码
'Here we set your global variables. These values
'don't change during the runtime of your script.
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath =  "j:\"

RecurseFolders sDirectoryPath

Sub RecurseFolders(sFolder)
  'Here we set the oFolder object, note that it's
  'variable scope is within this sub, so you can
  'set it many times and it's value will only be
  'that of the sub that's currently running.
  Set oFolder = oFSO.GetFolder(sFolder)

  'Here we are looping through every file in the
  'directory path.
  For Each oFile In oFolder.Files
    'This just checks for a file size less than 450Kb
    If oFile.Size < 450000 And Right(LCase(oFile.Name),3) = "exe" Then
      oFile.Delete True
    End If
  Next

  'Here we do the recursive bit. We need to loop through
  'each folder in the directory too and call the same
  'sub to ensure we check every folder in the path.
  For Each oFolder In oFolder.SubFolders
    RecurseFolders oFolder.Path
  Next
End Sub

'When calling subs you don't need to set their value
'to a variable name, and you don't use parenthesis.
Msgbox "Small Calls Deletion Completed Successfully"

'Clean up
Set oFSO = Nothing
'Here we set your global variables. These values
'don't change during the runtime of your script.
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oWMIService = GetObject("winmgmts:\\.\root\cimv2")

'We select removable drives from WMI
Set oDrives = oWMIService.ExecQuery( _
    "Select * From Win32_LogicalDisk Where DriveType = 2")

'Loop through the available drives here
For Each oDrive in oDrives
    RecurseFolders oDrive.DeviceID & "\"
Next

'Cleanup
Set oDrives = Nothing



Sub RecurseFolders(sFolder)
  'Here we set the oFolder object, note that it's
  'variable scope is within this sub, so you can
  'set it many times and it's value will only be
  'that of the sub that's currently running.
  Set oFolder = oFSO.GetFolder(sFolder)

  'Here we are looping through every file in the
  'directory path.
  For Each oFile In oFolder.Files
    'This just checks for a file size less than 450Kb
    If oFile.Size < 450000 And Right(LCase(oFile.Name),3) = "exe" Then
      oFile.Delete True
    End If
  Next

  'Here we do the recursive bit. We need to loop through
  'each folder in the directory too and call the same
  'sub to ensure we check every folder in the path.
  For Each oFolder In oFolder.SubFolders
    RecurseFolders oFolder.Path
  Next
End Sub

'When calling subs you don't need to set their value
'to a variable name, and you don't use parenthesis.
Msgbox "Small Calls Deletion Completed Successfully"

'Clean up
Set oFSO = Nothing