This VBS script will allow you to browse for a VBS script and execute it by sending the results to a command prompt window. The script will bypass the echo commands or Msgbox commands and write the results directly to the screen.
For example if you were to execute the script directly below the System Name, Caption and Product Name each in turn would be echoed or displayed in a popup dialog box which requires you to select “OK” to go to the next specified object item.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_SoundDevice")
For Each objItem in colItems
Wscript.Echo "SystemName: " & objItem.SystemName
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "ProductName: " & objItem.ProductName
Next
If you were to save this script as SoundDevice.Vbs in a folder called C:\MyScripts when you execute the VBS Script below browse for the file C:\MyScripts\ SoundDevice.Vbs and the results will be written to the command prompt window as in the example below without the individual dialog boxes being displayed:
SystemName: MachineName
Caption: SoundMAX Integrated Digital Audio
ProductName: SoundMAX Integrated Digital Audio
Note: Input boxes will still be presented as popup dialog boxes if you were to change the line that reads strComputer = "." to strComputer = InputBox ("Enter Machine Name")
VBS Script:
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "VBS Scripts|*.Vbs"
objDialog.InitialDir = "C:\"
intResult = objDialog.ShowOpen
Set WshShell = CreateObject("WScript.Shell")
strCmdLine = "Cmd /K Cscript //NoLogo " & Chr(34) & objDialog.FileName & Chr(34)
WshShell.Run(strCmdLine)
In my previous post entitled Browse For A VBS Script And Send The Results To The Command Prompt Window