先win+r打开系统运行框,输入regedit打开注册表
找到HYEK_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment下的path,双击进行修改
win11将下面代码复制粘贴
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
保存后重启电脑即可。