2012-01-28 111 views
1

我刚刚安装了PHP & Yii Framework。它工作正常,我玩CMD。但过了一段时间,我切换到PowerShell ISE。我浏览到Yii的文件夹:PowerShell问题 - 我必须输入./来运行bat文件

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 

然而,当我键入:

./yiic.bat

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

有没有办法来aviod打字我每次运行一个蝙蝠文件时间./

回答

2

我没有PowerShell来尝试了这一点,但如果你设置的路径,包括当前文件夹,这应该工作:

$env:Path = $env:Path + ";." 
+0

或者只是'$ Env:Path + =';。''。 – Joey 2013-07-31 15:43:26

+0

同意,谢谢乔伊! – 2013-08-01 01:12:46

+0

那简单而好看 – 2017-10-13 13:04:27

4

你想从运行该批处理文件的目录framework显然不在你的道路上。当您在shell中键入yiic.bat时,它会在您的path环境变量中包含的目录列表中查找该文件。有关如何在PowerShell中设置path的信息,请参阅this question

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

或者,正如mloskot所说,您可以将当前目录添加到您的路径中,但这可能会造成较小的安全风险。见例如this question对此进行了一些讨论。