3

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 ?

4

1 に答える 1

1

そうです、バッチファイルは直接実行可能ではなく、それらを実行するにはコマンドプロセッサが必要です。

とはいえ、移植性の問題の解決はかなり簡単であり、コンパイル時(プリプロセッサマクロを介して)または実行時(Windows固有の環境変数?スクリプトファイル名拡張?)のいずれかで実行できます。

私はおそらく前者をより堅牢なものとして使用するでしょう。

于 2013-01-05T12:26:01.070 に答える