Solved

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

Posted on 2013-06-27
5
575 Views
Last Modified: 2013-07-29
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;

c:\windows\system32>conApp.exe
v1.02.13
c:\windows\system32>

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?

Thanks,

Dave
0
Comment
Question by:dcadler
  • 2
  • 2
5 Comments
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 250 total points
ID: 39282081
Well amongst others you could pipe the output in:

conapp.exe | cscript //nologo testscript1.vbs

and in the VBScript:

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

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")

Steve
0
 
LVL 54

Accepted Solution

by:
Bill Prew earned 250 total points
ID: 39282598
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

~bp
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39282760
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.

Steve
0
 

Author Comment

by:dcadler
ID: 39346428
I will test this and let you know the results.
0
 

Author Closing Comment

by:dcadler
ID: 39364266
Thanks for you help
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Batch File- Finding Drive Description 11 39
pull links for all files in folder AND subfolder 15 53
global Variable - 2 functions in powershell 1 19
-OutVariable to Global 1 18
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question