Permanently altering a user's %PATH% environment variable via batch or Python

前端 未结 4 1605
梦毁少年i
梦毁少年i 2021-02-09 00:53

I\'ve been having difficulty with getting my users to set the PATH environment variable manually, I\'m looking for a way to do this automatically. A batch file would be prefera

4条回答
  •  独厮守ぢ
    2021-02-09 01:25

    I just ran across this question and didn't like any of the available options so I decided to write my own solution.

    (SetEnv would've been good, but I didn't like the non-libre license and I always prefer not having to call a subprocess... I wouldn't mind calling SetEnv as a subprocess but, according to Wikipedia, the license it uses is non-libre because it has some kind of "do no evil" clause and that kind of legally-ambiguous restriction is always a ticking time-bomb in my opinion.)

    Here's a little MIT-licensed Python class to hide away the work of modifying the registry directly and sending the WM_SETTINGCHANGE. (Good for use in setup.py)

提交回复
热议问题