Board logo

标题: [转载代码] [PowerShell每日技巧]查看PATH环境变量(20131217) [打印本页]

作者: DAIC    时间: 2013-12-26 10:39     标题: [PowerShell每日技巧]查看PATH环境变量(20131217)

The environment variable $env:Path lists all paths that are included in the Windows search path when you launch an application. Likewise, $env:PSModulePath lists all paths PowerShell searches for PowerShell modules (and includes in its module auto-loading).

These variables contain semicolon-separated information. Use the operator -split to view the paths separately:

PS> $env:path -split ';'
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\

PS> $env:PSModulePath -split ';'
C:\users\DAIC\My Documents\WindowsPowerShell\Modules
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\


http://powershell.com/cs/blogs/tips/archive/2013/12/17/displaying-path-environment-variables.aspx
作者: PowerShell    时间: 2014-1-1 13:00

驱动器,俗称盘符,c:   d:  这个样子。
---------------------------------------------------------
powershell帮我们把注册表的相关路径
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
映射成了盘符:
hkcu:      
hklm:               
-------------------------------------------------------------
把环境变量映射成了盘符
env:


所以你想要获取环境变量,用:

dir     env:      即可
--------------------------------------------------------
几个例子:

dir env:userprofile     -----显示用户目录如  C:\Users\user001
$aaa = (dir env:userprofile).value     ------赋值给变量aaa




欢迎光临 批处理之家 (http://bathome.net./) Powered by Discuz! 7.2