これを実行すると
file_path = convertfilepath("$temp/x.bat","windows");
savetextfile(file_path, "dir\!n");
rp = RunProgram( Executable( "cmd.exe" ),
Options( {"/C", file_path} ),
ReadFunction("text") // returns all text
);バットファイル実行の作業ディレクトリはデスクトップディレクトリのようです。 Pythonはコマンドラインでもファイル名を見つけるために作業ディレクトリを使用すると思います。 絶対パス名を使用するのが良い選択と思われます。
https://superuser.com/questions/396394/how-do-i-set-an-executables-working-directory-via-the-command-line-prior-to-ex起動コマンドで作業ディレクトリを指定できることを示唆しています。
START /D c:\temp notepad.exe
私が行っているネストされた呼び出しに関連する問題が発生しています。
RunProgram() --> cmd --> Python
次のバット ファイルは完全に正常に動作します。
set JMP_PYTHON_PTH=%UserProfile%\miniconda_JMP\
CALL %JMP_PYTHON_PTH%\Scripts\activate.bat %JMP_PYTHON_PTH%
start /B /wait "" python test.py
それでも、RunProgram() を使用する場合、Python ファイル (test.py --> 'C:/a/b/c/test.py') に絶対パスを追加しない限り、コードは失敗します。
ClearLog();
file_path = ConvertFilePath( "./tests/run_python_installation_test.bat", windows);
rp = RunProgram( Executable( "cmd.exe" ),
Options( {"/C", file_path} ),
ReadFunction("text") // returns all text
);絶対パスが指定されていない場合にのみ、次のエラーが発生します。
(base) C:\WINDOWS\system32>start /B /wait \!"\!" python test.py
python: can't open file 'test.py': [Errno 2] No such file or directory