Question

I am using boost.process to run an external process with some given input. user can specify that external process. So most of the time user specifies a shell script or batch script.

I am simply doing boost::process::launch(_script, arguments, context); which works both real executables as well as shell scripts as long as they are executable (+x) as expected. but when I run it in windows. it doesn't work If I pass a batch file in _script however it works if I specify a real executable.

This makes me think that in Windows batch scripts are NOT executables at all ? They are just interpreted through cmd.exe ! is this true ?

I can launch cmd.exe and specify /c _script argv as command line parameters. but that will not be cross platform.

and I don't want to make system() calls because I'll not have full control on created processes ?

Was it helpful?

Solution

That's right, batch files are not directly executable and require a command processor to run them.

That said, solving the portability issue should be fairly straightforward, and can be done either at compile-time (via preprocessor macros) or run-time (Windows-specific environment variables? script filename extension?)

I'd probably go with the former as more robust.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top