编写自己的配置文件

来源:互联网 发布:c语言高级编程实例 编辑:程序博客网 时间:2024/05/16 14:33
 
将自己的应用程序加到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-helpabout_signning命令查看原因

 

Set-ExecutionPolicyUnrestricted  更改策略,可以运行脚本

这个操作在注册表中的操作:在  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


原创粉丝点击