当前位置:网站首页>[PowerShell] command line output and adding system environment variables
[PowerShell] command line output and adding system environment variables
2022-06-12 05:53:00 【Amos-Chen】
View a system variable
Q: How to use Windows PowerShell View my environment variables Path, Which folders are there and the order in which they are displayed ?
A: Use $ env And get the Path The value of the variable . By default , It is displayed as a continuous string , It may be a little hard to read . The order is as follows :
$env:path
however , If you use –split Operator breaks a string at a semicolon , It is more readable :
$env:path -split“;”

other
such as : Check the system
$env:os
such as : System cores CPU
$env:NUMBER_OF_PROCESSORS
Be careful : View these environment variables , It must exist in the environment variable , Or you added it yourself .
Modify environment variables
First understand a thing : stay Windows On , You can define environment variables in three scopes :
- System level (Machine)
- User level (User)
- Session level (Process), Which means turn it off powershell Is the failure , This list of variables is inherited from the parent process , And it's based on Machine and User Variables in the scope are constructed .
user & System & Session level

In the picture :· User variables Corresponding user level scope , System variables Corresponding to the system level scope .
Add... On the basis of the original environment variables , And specify the scope ( user or System or conversation ), One command is done :
$addPath=‘c:\add\you\path\here’; $target=‘User’ ; $path = [Environment]::GetEnvironmentVariable(‘Path’, $target); $newPath = $path + ‘;’ + $addPath; [Environment]::SetEnvironmentVariable(“Path”, $newPath, $target)
Be careful :
$addPathThe equal sign is followed by the path you want to add$targetThe equal sign is followed by the scope ,Machine( System level ) /User( User level ) /Process( Session level ) Choose one of three , The first two amendments will take effect in time , And turn off powershell The conversation is still valid .- Other places don't need to be changed , Direct execution
Session level modification - Method 2
Add a new environment variable
$env:amostest=“amos for test desc”
Add... To the existing environment variables
$env:path+=";c:\your_path"
Reference resources
边栏推荐
- Nrf52832 services et fonctionnalités personnalisés
- Details of FPGA syntax
- Go interface oriented programming practice
- Halcon 3D 1 读取3d数据
- Go 面向接口编程实战
- [Speech] 如何根据不同国家客制化ring back tone
- 将一个文件夹图片分成训练集和测试集
- nus_ data_ Handler source code interprets data types such as structure
- Towards End-to-End Lane Detection: an Instance SegmentationApproach
- beginning一款非常优秀的emlog主题v3.1,支持Emlog Pro
猜你喜欢

Halcon 用点来拟合平面
![【长时间序列预测】Aotoformer 代码详解之[4]自相关机制](/img/12/27531fc791b3f49306385831309c5e.png)
【长时间序列预测】Aotoformer 代码详解之[4]自相关机制

Data integration framework seatunnel learning notes

March 23, 2021

Annotation configuration of filter

数据集成框架SeaTunnel学习笔记

Halcon 3D 1 读取3d数据

Redis memory obsolescence strategy

Available RTMP and RTSP test addresses of the public network (updated in March, 2021)

Role and understanding of proc/cmdline
随机推荐
WiFi band resources
Lesson 5: data warehouse construction (III)
Flex/fixed upper, middle and lower (mobile end)
Laravel8 authentication login
Redis cluster cluster capacity expansion and data migration
Halcon uses points to fit a plane
Introduction to thread pool: ThreadPoolExecutor
Glossary of Chinese and English terms for pressure sensors
Nrf52832 -- official routine ble_ app_ UART adds the LED feature to enable the computer UART and mobile app to control the LED on and off of the development board
nus_ data_ Handler source code interprets data types such as structure
Introduction to Internet Protocol
Why can't NAND flash be used as RAM while nor flash can
The application could not be installed: INSTALL_FAILED_TEST_ONLY
Research Report on market supply and demand and strategy of China's digital camera lens industry
Thesis reading_ Figure neural network gin
Quickly master makefile file writing
Beginning is an excellent emlog theme v3.1, which supports emlog Pro
Leetcode simple problem: converting an integer to the sum of two zero free integers
IO stream introduction
log4j 1. X upgrade to 2 Solution of X dependency incompatibility