Solved

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

Posted on 2013-06-27
5
560 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
Comment Utility
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 51

Accepted Solution

by:
Bill Prew earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
I will test this and let you know the results.
0
 

Author Closing Comment

by:dcadler
Comment Utility
Thanks for you help
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
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)
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now