Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

help needed with attempt at Windows Backticks equivelant or Stdout-to-var question please!

help needed with attempt at Windows Backticks equivelant or Stdout-to-var question please!

help needed with attempt at Windows Backticks equivelant or Stdout-to-var question please!

Hi all,thumbsup2
Firstly thanks in advance for any advice given in this area!
My question is in two parts, the main component is related to Vbscript but a proportion of the question is related to batch files also?
Here goes I am trying to put together a batch script which is basically a calling file to a VBscript routine which will do the following:
SET STDOUT2VAR="%~dp0MyProg.exe (Switch(s))"
call cscript "%~dp0BackTicks.vbs"
The above batch would call Backticks.vbs which would be hardcoded with the Variable STDOUT2VAR, The Stdout of the program/command would then be then redirected to a variable (Possibly) several lines output dependant on the STDOUT2VAR program/command, I think it is called Command Substitution. I know that the For /F command can do this at a pinch but have been advised that VBscript would be better to undertake this task. I have found this example of script (taken from "Redirect Command line utility output to variable?" on Tek-Tips) that I was wondering could be adapted to accomplish this request
Set oShell = CreateObject ("WScript.Shell")
Set oExec = oShell.Exec("CMD.EXE /C DIR C:")
Do While oExec.Status = 0
WScript.Sleep 100
myArray = Split(oExec.StdOut.ReadAll, vbCrLf)
Also P.S. is there anyway that within the Vbscript that the equivelant of exit /b command could occur (that is to return to the calling batch file once the BackTicks.vbs file completes its task?
Kind regards,

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close