How to execute files without specifying a path.

5 visualizaciones (últimos 30 días)
han han
han han el 9 de Dic. de 2019
Comentada: Walter Roberson el 9 de Dic. de 2019
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

Respuestas (1)

Bhaskar R
Bhaskar R el 9 de Dic. de 2019
Editada: Bhaskar R el 9 de Dic. de 2019
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 comentarios
Bhaskar R
Bhaskar R el 9 de Dic. de 2019
Set xxx.exe as environmental variable, then execute your code
Walter Roberson
Walter Roberson el 9 de Dic. de 2019
You should add the directory containing the executable to the PATH environment variable.

Iniciar sesión para comentar.

Categorías

Más información sobre Search Path en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by