0

Exactly what it says. I can set per-user environment variables, either from Windows > type "Path", or using RegEdit, or even from a Python script.

But if I run an application (e.g. from Launchy, or launch it from Chrome), it won't pick up the new variables. I've got to start a new cmd or Windows Explorer (I think) to get the new values.

Now, obviously I can set them on a per-use basis, but I want to set them globally for my account, and also for whatever process I happen to be using at the time. Is this possible? And is it possible (or easier) to do from a Python script?

4

1 に答える 1

3

レジストリで (または [システム プロパティ] > [詳細設定] > [環境変数] UI を介して) 環境変数を設定すると、変数が設定された後に作成されたトップ レベルのコンテキストから起動されたすべてのプロセスに対してグローバルで永続的になります。ただし、変更前に初期化されたシェルとコンテキストは、レジストリの値をそのコンテキストの既存の値と明示的にマージしない限り、それらの変更を反映しません。各コンテキストはその親の環境を継承しますが、それ以降は、親環境または子環境への変更はどちらの方向にも伝播しません。最上位で作成されたコンテキストは、レジストリから環境を取得します。

于 2013-02-26T21:20:50.873 に答える