DOS..BAT VB Progamming problem

T

TomD

I have a program that prints to the screen. From a DOS window, or with a BAT
file I can redirect the data to a file via the following command "Path Arg1
Arg2 >Filename. But, when I execute the BAT file from a VB program, using
either Shell or FollowHyperlink, the output file is created or recreated but
remains empty. Any help will be greatly appreciated.

TomD
 
R

Rick Rothstein

This is only a guess, but try adding a call to the Command Processor in your
Shell statement, something like this...

Shell Environ("COMSPEC") & " c:\Path\To\BatFile\NameOfBatFile.bat"

Note the space in front of the path string.
 
T

TomD

HI guys,

Thanks for the help.

I have found a partial solution to my problem as shown below:

varProc = Shell("cmd /c c:\Program.exe arg1 arg2 >c:\InputData.txt")

But, the problem is that the Executable will not always be in a Root
Directory, as different people will put it in different places. It is,
however, explicitively implied that it be in the same directory as the
WorkBook.

Therefore I tried this method and it fails:

FileName = ActiveWorkbook.Path & "\Program.exe arg1 arg2 >c:\InputData.txt"

Thanks in advance for any help that you can give me,
Tom
 
T

TomD

Whoops, I forgot to show the resulting command, whic is as follows:

varProc = Shell("cmd /c FileName")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top