LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Running batch files and redirecting output to a file in LabwindowsCVI

I am trying to run a batch file which gives output to command prompt. I want to capture that data to a file.
I am using LaunchExectableEx(d:\\myfile.bat >d:\\trial.txt,"",handle).This command creates a file, but there is no data in the file.
Can anyone help me in this regard?
0 Kudos
Message 1 of 3
(5,789 Views)
Hello ax,
 
I wasn't able to reproduce the problem you are seeing.  I created a quick batch file:
@echo off
echo Hello World
pause
 
and ran the following command:
LaunchExecutable ("c:\\helloworld.bat > c:\\helloworld.txt");
 
and the output file was correctly written and saved.
 
Thanks.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 2 of 3
(5,758 Views)
Just a guess. The > operator only redirects output written to standard output; not standard error. If the batch file calls things which write to standard error, that output would not be captured in the file.
 
Try:  LaunchExectableEx("d:\\myfile.bat 2>&1 > d:\\trial.txt","",handle);
 
This will redirect both standard out and error to the file.
 
Hope this helps,
 
-alex
0 Kudos
Message 3 of 3
(5,753 Views)