windows – 为什么setx路径不起作用?
|
有人可以解释这个结果吗? 设置路径后,它没有改变.这是在管理员命令行中运行的: C:Windowssystem32>setx path "C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:ProgramDatachocolateybin;D:Program Files (x86)Microsoft VS Codebin" SUCCESS: Specified value was saved. C:Windowssystem32>path PATH=C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:ProgramDatachocolateybin;D:Program Files (x86)Microsoft VS Codebin;D:Program Files (x86)metapad36;D:Program Files (x86)metapad36" /M 我已经读过用户的机器PATH变量的%PATH%= PATH变量.我看到机器路径Admin的路径了吗? 看过关于这个话题的其他文章,但仍然困惑. 我应该清除用户路径,所以没有重复吗? 更新:重新提示“此工具创建或修改的变量将在以后的命令窗口中可用”我打开一个非管理员窗口并输入: >path PATH=C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:ProgramDatachocolateybin;D:Program Files (x86)Microsoft VS Codebin;;D:Program Files (x86)metapad36;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:ProgramDatachocolateybin;D:Program Files (x86)Microsoft VS Codebin 路径重复两次.好的,然后在相同的提示我设置路径没有重复,没有/ M: >setx path "C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:ProgramDatachocolateybin;D:Program Files (x86)Microsoft VS Codebin" SUCCESS: Specified value was saved. 显然保存在当前用户环境中. 然后我打开一个新的非管理命令窗口,并: >path PATH=C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:ProgramDatachocolateybin;D:Program Files (x86)Microsoft VS Codebin;;D:Program Files (x86)metapad36;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:ProgramDatachocolateybin;D:Program Files (x86)Microsoft VS Codebin` 它没有改变.为什么? 在Windows中,每个进程都获得一个环境副本,该环境本质上是进程启动时全局环境的快照.进程运行时对全局环境的更改不会传播回进程自己的环境副本.要回答实际问题,setx会修改用户环境(如果使用/ M运行,则会修改系统),但在执行setx的进程中不会立即看到更改,在本例中为cmd.exe.如果在运行setx后打开新的命令提示符,则会在该cmd.exe实例中看到更改. 这在setx /中明确指出.救命:
要在全局环境和当前进程中实现相同的更改,您需要同时运行setx和set. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
