将自己的应用程序加到PowerShell的配置文件中。
首先在C:/Users/hp/Documents/WindowsPowerShell的创建profile.ps1,启动新的PowerShell出现下面的错误:
无法加载文件 C:/Users/hp/Documents/WindowsPowerShell/profile.ps1。文件 C:/Users/hp/Documents/Window
sPowerShell/profile.ps1 未经数字签名。系统将不执行该脚本。有关详细信息,请参阅 "get-help about_sign
ing"。。
所在位置 行:1 字符: 2
+ . <<<< 'C:/Users/hp/Documents/WindowsPowerShell/profile.ps1'
使用 get-help about_signning命令查看原因
Set-ExecutionPolicy Unrestricted 更改策略,可以运行脚本
这个操作在注册表中的操作:在 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/PowerShell/1/ShellIds/Microsoft.PowerShell 中 增加一项
ExecutionPolicy REG_SZ Unrestricted
让自己的运用程序可以在PowerShell上运行。
function kmplayer
{
& 'C:/Program Files/KMplayer/KMPlayer.exe'
}
重启 PowerShell后即可在终端上使用 kmplayer