如何将脚本添加到路径?

Ari*_*Ari 5 script powershell path windows-8

我将常用的 powershell 脚本存储在%USERPROFILE%\Bin. 我创建了一个USER_BIN环境变量,我PATH通过Control Panel > System and Security > System > Advanced system setting > Environment Variables.

当我在cmd 或 powershell 提示符中输入存储在Bin, 即中的脚本的名称时,my-script.ps1我收到消息my-script.ps1 : The term 'my-script.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

如果我提供完整路径,即C:\Users\Ari\Bin\my-script.ps1脚本工作正常。

Jac*_*001 0

Windows 在登录时初始化 CMD 和 Powershell 的路径。您需要先注销并重新登录,然后才能检查新目录。