How to set environment variables for current account that can be used by other applications?
古いコメントを表示
In a matlab script, I am trying to edit the environment variable , namely "Path" for the current user.
Now, getenv("Path") gives all the Path variable available including the system-wide path variables but I am only trying to access the current user's Path environment variable.
So I opted for:
current_path = winqueryreg('HKEY_CURRENT_USER','Environment','Path');
This returns the Path Variable just for current user as a character array which I can easily manipulate/edit, remove and add the desired path to it.
edited_path = edit_path(current_path);
My problem is : I want to set this character array as the Path variable for the current user. I tried doing it with the system command.
system('setx Path =edited_path')
However, it simply returns 0 and does not work . I even tried just a basic thing like :
system('setx Path ="test"');
This did not seem to work either.
I also tried with the set command instead of setx because it is just the current session that needs the environment variable but that did not work either.
Now, I could opt for setenv but I am not sure if this would affect the environment variables for other tools/applications.
The idea is : the script would run another application through a bat file that needs to use the changed environment variable.
Is there any way to go about this?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Installing Products についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!