PowerShell问题 - 我必须输入./来运行bat文件

dra*_*fly 1 powershell powershell-2.0

我刚刚安装了PHP和Yii Framework.它工作正常,我玩CMD.但过了一段时间我转而使用PowerShell ISE.我导航到Yii文件夹:

cd C:\ dev\yii-1.1.9.r3527\framework

我发出命令:

yiic.bat

我收到一个错误:

PS C:\dev\yii-1.1.9.r3527\framework> yiic.bat
The term 'yiic.bat' 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.
At line:1 char:9
+ yiic.bat <<<< 
    + CategoryInfo          : ObjectNotFound: (yiic.bat:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)

但是,当我键入:

./yiic.bat

进入PowerShell窗口,它工作正常.

有没有一种方法来aviod打字./我每次运行时BAT文件?

Dav*_*vid 5

framework您尝试运行批处理文件的目录显然不在您的路径中.键入yiic.batshell时,它会在path环境变量中包含的目录列表中查找该文件.有关如何设置powershell的信息,请参阅此问题path.

例如,如果您希望能够在C:\dev\yii-1.1.9.r3527\framework目录中运行批处理文件,您可以说$env:Path = $env:Path + ";C:\dev\yii-1.1.9.r3527\framework".

或者,正如mloskot所说,您可以将当前目录添加到路径中,但这可能会带来轻微的安全风险.请参阅此问题,以便对此进行一些讨论.