• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 593
  • Last Modified:

How can I pass the output of an EXE file as a parameter into a vbscript file?

I have an executable program called conApp.exe, that retrieves information from BIOS and displays it to the screen as a string of text.

So, if I type conApp.exe from an elevated command prompt, I get the text string displayed to the screen

For example;


Typically I redirect that output to a text file so I can use it in another script.

for example; c:\windows\system32>conApp.exe > biosVer.txt

What I would like to do is pass the string of text generated by conApp.exe into variable in a VBScript file and manipulate that text within the VBScript.

for example; testscript1.vbs conApp.exe

How can I do this?


  • 2
  • 2
2 Solutions
Steve KnightIT ConsultancyCommented:
Well amongst others you could pipe the output in:

conapp.exe | cscript //nologo testscript1.vbs

and in the VBScript:

Do Until WScript.StdIn.AtEndOfStream
   strAll = strAll & WScript.StdIn.ReadLine & chr(10)

wscript.echo "The output was: " & strAll

or redirect to a file within the vbscript to run the conapp.exe there:

wShell.Exec( "%comspec% /c conapp.exe > biosver.txt")

Bill PrewCommented:
If the output of the EXE is just a single string then you can do it this way, capturing the output of the command into a variable, then passing that into the VBS as a command line parm.  In the VBS grab the parm from the command line as documented here: http://ss64.com/vb/arguments.html.

@echo off
for /F "tokens=*" %%A in ('conapp.exe') do set BiosVer=%%A
cscript testscript1.vbs "%BiosVer%"

Open in new window

Steve KnightIT ConsultancyCommented:
Good point Bill.  You could almost certainly do away with the need for the EXE altogether and just query the bios setting you want too directly in the VBS.

dcadlerAuthor Commented:
I will test this and let you know the results.
dcadlerAuthor Commented:
Thanks for you help
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now