Hi all,
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:
::==================Start=================::
@ECHO OFF
SET STDOUT2VAR="%~dp0MyProg.exe (Switch(s))"
call cscript "%~dp0BackTicks.vbs"
EOF
::===================End===================::
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
::=================start==================::
Set oShell = CreateObject ("WScript.Shell")
Set oExec = oShell.Exec("CMD.EXE /C DIR C:")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
myArray = Split(oExec.StdOut.ReadAll, vbCrLf)
::=================end====================::
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,
David
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:
::==================Start=================::
@ECHO OFF
SET STDOUT2VAR="%~dp0MyProg.exe (Switch(s))"
call cscript "%~dp0BackTicks.vbs"
EOF
::===================End===================::
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
::=================start==================::
Set oShell = CreateObject ("WScript.Shell")
Set oExec = oShell.Exec("CMD.EXE /C DIR C:")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
myArray = Split(oExec.StdOut.ReadAll, vbCrLf)
::=================end====================::
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,
David