重新加载PowerShell中的路径

16 浏览
0 Comments

重新加载PowerShell中的路径

如果我正在运行 PowerShell ISE 实例并且安装了修改 PATH 的东西,或者在 PowerShell 之外以任何方式修改了它,那么我需要重新启动 PowerShell 才能看到更新后的 PATH 变量。有没有一种方法在 PowerShell 中重新加载路径,而不必重新启动它?

admin 更改状态以发布 2023年5月23日
0
0 Comments

\n\n尝试获取机器路径并将其分配给会话路径。 \n

$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")

0
0 Comments

这里是为了引用Rob的评论:

$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") 

0