List all environment variables from the command line

前端 未结 8 1368
星月不相逢
星月不相逢 2020-11-28 17:01

Is it possible to list all environment variables from a Windows\' command prompt?

Something equivalent to PowerShell\'s gci env: (or ls e

相关标签:
8条回答
  • 2020-11-28 17:29

    If you want to see the environment variable you just set, you need to open a new command window.

    Variables set with setx variables are available in future command windows only, not in the current command window. (Setx, Examples)

    0 讨论(0)
  • 2020-11-28 17:37

    Jon has the right answer, but to elaborate a little more with some syntactic sugar..

    SET | more
    

    enables you to see the variables one page at a time, rather than the whole lot, or

    SET > output.txt
    

    sends the output to a file output.txt which you can open in Notepad or whatever...

    0 讨论(0)
  • 2020-11-28 17:42

    To list all environment variables in PowerShell:

    Get-ChildItem Env:
    

    Or as suggested by user797717 to avoid output truncation:

    Get-ChildItem Env: | Format-Table -Wrap -AutoSize
    

    Source: Creating and Modifying Environment Variables (Windows PowerShell Tip of the Week)

    0 讨论(0)
  • 2020-11-28 17:44

    Don't lose time. Search for it in the registry:

    reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
    

    returns less than the SET command.

    0 讨论(0)
  • 2020-11-28 17:47

    As mentioned in other answers, you can use set to list all the environment variables or use

    set [environment_variable] to get a specific variable with its value.

    set [environment_variable]= can be used to remove a variable from the workspace.

    0 讨论(0)
  • 2020-11-28 17:49

    Simply run set from cmd.

    Displays, sets, or removes environment variables. Used without parameters, set displays the current environment settings.

    0 讨论(0)
提交回复
热议问题