1. 程式人生 > >使用setx 命令新增環境變數(Windows)

使用setx 命令新增環境變數(Windows)

背景

用GUI的方法可能新增環境變數可能會比較麻煩,為此可採用命令列操作的方式。

步驟

  1. 以管理員身份執行 cmd 輸入 setx \M "path" "%path%[new_path];"。其中\M開關表示新增系統變數,由於%path%` 本身是系統變數和使用者變數拼起來的,不能用此方法新增使用者變數。
    詳見https://superuser.com/questions/601015/how-to-update-the-path-user-environment-variable-from-command-line
  2. 設定在新的命令列視窗生效。