PowerShell profile.ps1未在启动时运行

时间:2014-08-24 06:57:34

标签: powershell vim profile

我最近开始使用PowerShell。我一直在尝试设置我的profile.ps1来为vim添加别名。

我编辑了profile.ps1示例,然后将其移动到C:\ Windows \ System32 \ WindowsPowerShell \ v1.0

这似乎是正确的位置,因为我收到错误,指出在此计算机上未启用运行脚本。所以我以管理员身份运行PowerShell并运行此命令:

Set-ExecutionPolicy RemoteSigned

哪个摆脱了错误信息,但我的脚本似乎仍无所作为。它看起来像这样:

#  Copyright (c) Microsoft Corporation.  All rights reserved.
#  
# THIS SAMPLE CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
# WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
# IF THIS CODE AND INFORMATION IS MODIFIED, THE ENTIRE RISK OF USE OR RESULTS IN
# CONNECTION WITH THE USE OF THIS CODE AND INFORMATION REMAINS WITH THE USER.
Write-Host "Hello world"
Set-Alias vim ' C:\Program Files (x86)\Vim\vim74\vim.exe'

键入“vim”并且“hello world”未打印时,Vim仍然无法启动。

1 个答案:

答案 0 :(得分:1)

如果您运行的是PowerShell的x86(32位)版本,则路径应为C:\ Windows \ SysWOW64 \ WindowsPowerShell \ v1.0。也就是说,当32位进程查找C \ Windows \ System32时,Windows文件系统虚拟化将启动并将其重定向到C:\ Windows \ SysWOW64。

或者只是将配置文件移到CurrentUserAllHosts路径,您不必担心32位与64位PowerShell。