Loading
Scriptbox
 VBScript Links 
 About VBscript 
 JavaScript Links 
 About JavaScript 
 Powershell Links 
 PSCRIPT the Script Launcher 
 PowerShell Shortcut Keys 
 About Powershell 
     VBScript
    JavaScript
    Powershell
Disclaimer
Contact
Latest 10 Scripts
Script search
  :: { Category } :: 0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ
         

Search Options:  Get  the  Names  of  10  Randomly-Selected  Files  in  a  Folder  

 Content of Get the Names of 10 Randomly-Selected Files in a Folder.vbs
MD5 Hash: 8E9FEF58C674E18D6A9FDD8425BC0BFA
strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='C:\Scripts'} Where " _
& "ResultClass = CIM_DataFile")

intFiles = colFiles.Count

Set objDictionary = CreateObject("Scripting.Dictionary")

intHighNumber = intFiles
intLowNumber = 1

For i = 1 to 10
x = 0
Do Until x = 1
Randomize
intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)
If objDictionary.Exists(intNumber) Then
x = 0
Else
objDictionary.Add intNumber, intNumber
x = 1
End If
Loop
Next

i = 1

For Each objFile in colFiles
If objDictionary.Exists(i) Then
Wscript.Echo objFile.Name
End If
i = i + 1
Next



   © 2008 - 2013 Boris Toll      :: Scripts available: 6.481 ::      :: scriptbox.toll.at ::      :: powered by www.toll.at ::
  Google Entries:n/a
  Yahoo Backlinks:n/a
  Live Backlinks:n/a
  del.icio.us Bookmarks:n/a
  Technorati Links:n/a