DEV Community

Cover image for Windows set up system environment variables
FakeStandard
FakeStandard

Posted on • Edited on

1

Windows set up system environment variables

Windows System 內建許多環境變數,可透過 CMD 直接下指令或是使用 GUI 查詢或變更

CMD

例如:使用 set 指令列出全部環境變數

cmd-001

set 指令同時也可以新增和變更 Environment Variable

建立一個名為 ev 的變數,值為 test

set ev=test
Enter fullscreen mode Exit fullscreen mode

使用 set 查看環境變數,也可使用 echo 指令印出變數值

set ev
echo %ev%
Enter fullscreen mode Exit fullscreen mode

變更環境變數的值與新增的指令一樣,前提是變數已存在,若不存在則是執行新增動作

set ev=exist
Enter fullscreen mode Exit fullscreen mode

刪除環境變數一樣使用 set 指令,列出要刪除的環境變數,等號右邊不要添加任何值

set ev=
Enter fullscreen mode Exit fullscreen mode

使用 CMD 要注意一個地方,當 CMD 關閉後,所設置的環境變數都會消失,必須重新設置,適合一次性的使用,若需要常駐於系統中,則要到控制台設置。

GUI/control

打開控制台/control,前往 控制台\系統及安全性\系統

pic-001

進階系統設定

pic-002

環境變數

pic-003

環境變數內分為「使用者變數」和「系統變數」,使用者變數是目前登入的使用者獨立的設定,而系統變數是全域的,所有使用者都會套用此設定。

此介面一樣可以增刪修,而操作結果會常駐於系統中,重新開機後也會存在,無須重新設定。


Thanks for reading the article 🌷 🌻 🌼

If you like it, please don't hesitate to click heart button ❤️
or follow my GitHub ⭐ I'd appreciate it.


Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay