3

I am trying to write a VB code where a .bat file is loaded from VB then according to the outcome of the batch file other actions are taken from VB.

For launching the .bat file from VB no probs.

My problem comes when I need to pick the contents of a variable named status used in the .bat file and transfer it into a variable in the VB code.

Any ideas, suggestions are appreciated?

Ivan
  • 31
  • 1

2 Answers2

1

Try redirecting the results of the batch file to another file like...

C:\>dir *.* > result.txt

Where your VB app can look for (result.txt), open it read it after it's created by the .bat file

Rose
  • 641
  • 7
  • 17
  • You might need your .bat to right out a second file, after result.txt. A second file that lets your VB app know that result.txt is actually done being created. Depending on what your .bat file is doing, result.txt could show up on your drive before it's done being written to, closed etc. – Rose Nov 14 '14 at 17:11
0

You cannot read the environ variables of the batchfile directly as they belong solely to that process.

Read the comments on this MSDN page for more detailed info

The only solution would be to make the batchfile store the result somewhere else where vb6 can read it like in a file or the registry.

I always like creating a section in the registry for my VB6 app and store my data there.

In a batch file you can write to the registry via the reg add command.

Have a look at this post at stackoverflow for some more comments on the reg add command

Community
  • 1
  • 1
Hrqls
  • 2,944
  • 4
  • 34
  • 54