Solved

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

Posted on 2013-06-27
5
580 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Powershell GUI 11 95
size of file 1 36
Hta File displays dynamic File names 4 65
can this macro be converted to sub procedure 4 33
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

734 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