Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-06-27
5
Medium Priority
?
588 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 1000 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 57

Accepted Solution

by:
Bill Prew earned 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
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)

705 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