필터 지우기
필터 지우기

How to execute files without specifying a path.

조회 수: 4 (최근 30일)
han han
han han 2019년 12월 9일
댓글: Walter Roberson 2019년 12월 9일
As the title, I don't want to execute cmd in a specified or specific directory, but it can be executed no matter which directory I execute the file in.
How can it be modified?
out = fileread('1.txt');
cmd = ['xxx.exe', out];
system(cmd)
THX

답변 (1개)

Bhaskar R
Bhaskar R 2019년 12월 9일
편집: Bhaskar R 2019년 12월 9일
You can but
  1. Files shold be in present working directory
  2. Program(here xxx.exe) should set to environmental variable if it is not present in the present workind directory
Code
cmd = ['xxx.exe', ' ', '1.txt'];
system(cmd);
  댓글 수: 3
Bhaskar R
Bhaskar R 2019년 12월 9일
Set xxx.exe as environmental variable, then execute your code
Walter Roberson
Walter Roberson 2019년 12월 9일
You should add the directory containing the executable to the PATH environment variable.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by