Error when I run a .bat file

1 回表示 (過去 30 日間)
Asterix Legaulois
Asterix Legaulois 2017 年 8 月 2 日
コメント済み: Asterix Legaulois 2017 年 8 月 2 日
Hello. When i try to run a .bat file from matlab, an error appears in a cmd window: "terminate called after throwing an instance of 'std::logic_error' what(): Could not find user home direct" What should I do to correct this ? PS: when I run it from the cmd window, every thing works correctly. Thanks for your help.
  2 件のコメント
José-Luis
José-Luis 2017 年 8 月 2 日
How are you running said file?
Are you using a system() call?
Asterix Legaulois
Asterix Legaulois 2017 年 8 月 2 日
Yes I tried this way, but I also try to use this little program:
batFile = 'c:\name_folder\name_file.bat';
startInfo = System.Diagnostics.ProcessStartInfo('cmd.exe', sprintf('/c "%s"', batFile));
proc = System.Diagnostics.Process.Start(startInfo);
if isempty(proc)
error('Failed to launch process');
end
while true
if proc.HasExited
fprintf('\nProcess exited with status %d\n', proc.ExitCode);
break
end
fprintf('.');
pause(.1);
end
I think the problem comes from the way that matlab is using "cmd", maybe I don't have all the right, or something like that... Maybe their is some thing to change in "startInfo" but I don't know what :)

サインインしてコメントする。

回答 (1 件)

ES
ES 2017 年 8 月 2 日
Is there any reason why you dont use
!abc.bat
or
dos('abc.bat')
  1 件のコメント
Asterix Legaulois
Asterix Legaulois 2017 年 8 月 2 日
I tried this, but I have the same error, so I tried an other way, with more parameters

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by