Shell/DOS commands from JUCE?


#1

Hi,

I was wondering if JUCE has a way to execute shell/DOS commands? stdlib.h has a way of doing it through the system() command, however this is not very flexible: it always opens a command window and you can’t do anything with any text that gets generated on the console; would be nice to have a way to execute commands that doesn’t open a shell window, and returns the output as a String so it can be used in a JUCE Label or whatever.

Thanks in advance!


#2

Use ShellExecute, There is a flag to not create the output window. As well, it returns a handle you can wait on. Direct the output of the program to a file and then read the file. I could post example code later.


#3

Thanks for the help. I had seen ShellExecute() previously but am reluctant to use it as there is a chance my code may need to be ported to Linux in future; would have been nice to be able to use a Juce function since then it would be more cross-platform. Thanks anyway!