LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically Read/Write from application console

Solved!
Go to solution

Hello All,

I am developing a VI which would Write a string to a third party console application (running on DOS) and then read the data from this console back into LabVIEW. I think this is possible by using the Windows API, but I would like to know which would be the best method to implement this.

 

 

Thanks

 

FraggerFox

-FraggerFox!
Certified LabVIEW Architect, Certified TestStand Developer
"What you think today is what you live tomorrow"
0 Kudos
Message 1 of 6
(4,935 Views)

Hmmm.  Little unsure what you mean here.  Are you trying to execute a command line statement and then read back the response?  Couldn't you just use System Exec for this:

 

http://zone.ni.com/reference/en-XX/help/371361G-01/glang/system_exec/

 

Or perhaps you could store your commands in a batch file, then run the batch and output the results to a text file.  This is done like this:

 

     batch_file.bat >output.txt

http://www.medicollector.com
0 Kudos
Message 2 of 6
(4,893 Views)
Solution
Accepted by FraggerFox

DOS is an operating sytem. It's not Windows (though there are remnants of DOS within the source code of Windows). So, to say something is running on DOS implies it's running on a different computer. Is this the case? There's the command window in Windows. Is that what you are referring to? So, is this a command-line application? If so, yes, there is a way to use the Windows API to capture the contents of the command line window and to paste contents into it. I showed an example in this thread: Re: URGENT!!! How we read stdout directly?

Message 3 of 6
(4,883 Views)

Just rewire the error clusters in the broken VI in smercurio's example, which is explained in the example - caused by 8.2 ver bug.

Richard






0 Kudos
Message 4 of 6
(4,870 Views)

I just thought - if the OP's application is truly a console ap, wouldn't it report back to the console? And all that would be required is something like this? (where "mem" = the 3rd party command line with all arguments).

 

 

ReadDOScmd.png

Richard






0 Kudos
Message 5 of 6
(4,859 Views)

@smercurio_fc

 

I think the example in this link would solve 80% of my problem. I would need to make some changes here before finally using it.

I used some different kernel32 commands before posting this here, in which I would need to use the FreeConsole() function, which I didn't want.

 

Thanks! 🙂

-FraggerFox!
Certified LabVIEW Architect, Certified TestStand Developer
"What you think today is what you live tomorrow"
0 Kudos
Message 6 of 6
(4,834 Views)