0

Am using a vbscript program in which i do the following process,

i call a bat file and based on it's out put i need to call another bat file.

for e.g one.bat and two.bat are the batch files..

one.bat file will print message "Success" or "fail" in command window. i have to read the string through vbscript and if success have to call two.bat

i have tried using exec but its opening a command window, i don't want any command windows to be opened in GUI while executing the VBS.

Am new to this please explain with example.

user2572985
  • 75
  • 1
  • 2
  • 8
  • You can use `.Exec()` method, without console window flash, temp files and unexpected WScript.Echo output muting, check [this answer](https://stackoverflow.com/a/32302212/2165759). – omegastripes Aug 06 '18 at 23:20

1 Answers1

0

As you can't avoid a console when you call .Exec from a GUI (.HTA?), you must use .Run. This answer shows how to capture the the output via files.

But: As you just need to know whether one.bat succeeded or failed, you could use .Run's return value (ERRORLEVEL/Exit code of one.bat) and avoid the problem of reading its output.

Community
  • 1
  • 1
Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96
  • one.bat is a compilation of java source code so it prints Success or Fail in command prompt itself in that case also (ERRORLEVEL/Exit code of one.bat) will work? – user2572985 Nov 11 '13 at 10:44
  • @user2572985 - why don't you just test whether one.bat sets ERRORLEVEL accordingly? – Ekkehard.Horner Nov 11 '13 at 10:57
  • if .Exec will invoke a console , is it possible to display some text in that?? cuz when i call one.bat thru .exec it is not displaying any text – user2572985 Nov 11 '13 at 11:46