'========================================================================= ' IDK.vbs ' VERSION: 1.0 ' AUTHOR: Brian Steinmeyer ' EMAIL: [email protected] ' WEB: https://sigkillit.com ' DATE: 12/8/2012 ' COMMENTS: If you have ever had an issue making a decision like "What Should ' I eat for dinner" or "What should I do tonight?" then IDK aka "I Don't Know" ' is the script for you. It will randomly select a decision for you from a line ' delimited text file you pass to the script. You can run the script with Wscript ' by dragging and dropping your file onto the script or with Cscript by using ' the file path as the argument passed. You can make lists for all types of ' decisions you commonly make, and a few ideas are Yes/No, Magic8Ball, Pizza Shops, ' Restaurants, Movies, etc. ' EXAMPLE: Drag-N-Drop with WScript ' Drag and Drop a file called Pizza.txt onto IDK.vbs to select a pizza shop ' EXAMPLE: From and command prompt with Cscript ' C:\>cscript IDK.vbs "C:\My Lists\pizza.txt" '========================================================================= Option Explicit Wscript.Echo IDK(wscript.arguments.item(0)) Private Function IDK(filePath) On Error Resume Next Const ForReading = 1 Dim strResult Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject") If Not objFSO.FileExists(filePath) Then strResult = "ERROR - Input File Does Not Exist!" Else 'Parse Input File into Array Dim objTextFile: Set objTextFile = objFSO.OpenTextFile(filePath, ForReading) Dim arrLine() Dim intSize: intSize = 0 Dim strLine, blnMatch: blnMatch = False Do Until objTextFile.AtEndOfStream strLine = Trim(objTextFile.Readline) If Not strLine = "" Then blnMatch = True ReDim Preserve arrLine(intSize) arrLine(intSize) = strLine intSize = intSize + 1 End If Loop 'Randomly Select Dim intHighNumber: intHighNumber = UBound(arrLine) Dim intLowNumber: intLowNumber = LBound(arrLine) Dim intNumber Randomize strResult = arrLine(Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)) End If 'Return Results If Err.Number <> 0 Then Err.Clear strResult = "ERROR - Parsing Input File!" End If IDK = strResult Set objFSO = Nothing On Error Goto 0 End Function