matlab - 从 MATLAB 中查找已安装程序的路径?

标签 matlab path installation

能否通过MATLAB命令行查看具体程序的安装路径? 或者我可以找到已注册程序的路径(相当于 Windows reg)吗?

最佳答案

这不会 100% 可靠,但大多数时候都会得到正确的答案:

function p = findOnSystemPath(f)
p = '';
path = getenv('path');
dirs = regexp(path,pathsep,'split');
for iDirs = 1:numel(dirs)
    tp = fullfile(dirs{iDirs},f);
    if exist(p,'file')
        p = tp;
        break
    end
end

使用示例:

>> findOnSystemPath('runemacs.exe')

ans =

C:\Program Files (x86)\emacs\bin\runemacs.exe

根据您的操作系统,您也许可以直接从系统获取此信息:

which 可在 Unix 系统和 Windows 系统上使用 Cygwin安装:

>> [~,p] = system(sprintf('which "%s"',f))

p =

C:/Program Files (x86)/emacs-mw-a/bin/runemacs.exe

where 可在 Windows 2003 and later 上找到:

>> [~,p] = system(sprintf('where "%s"',f))

p =

C:\Program Files (x86)\emacs-mw-a\bin\runemacs.exe

在某些情况下,您可以使用 winqueryreg 从注册表中提取此信息。 ,例如:

>> notepadEdit = winqueryreg('HKEY_CLASSES_ROOT','Applications\notepad.exe\shell\edit\command')

notepadEdit =

C:\Windows\system32\NOTEPAD.EXE %1

关于matlab - 从 MATLAB 中查找已安装程序的路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5818545/

相关文章:

python - scipy 在 linux 上安装 : can't find a lapack object sgges_

Matlab - 将两个视频合并为一个分屏视频

matlab - 从 MATLAB 中的 MSER 检测获取区域点?

c - 跳过 MEX 编译中的代码部分

string - 如何确定字符串是否是格式正确的路径,无论它是否实际存在?

python - 系统路径中安装了多个Python

path - Windows 7-添加路径

python - 全新安装 Anaconda 和 PyCharm 控制台后将无法连接,并出现 DLL 加载失败

matlab - 如何通过 MATLAB 使最小二乘线与散点图中相应数据集的颜色相同?

python - matplotlib.pyplot 问题 python