2

I've just installed PHP & Yii Framework. It works fine, I played with CMD. But after a while I switched to PowerShell ISE. I navigated to Yii folder:

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

and I issued command:

yiic.bat

and I get an error:

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

However when I type:

./yiic.bat

into PowerShell window, it works fine.

Is there a way to aviod typing ./ every time I run a bat file?

3 Answers 3

4

The framework directory you're trying to run the batch file from is evidently not in your path. When you type yiic.bat into the shell, it looks for that file in the list of directories contained in your path environment variable. See this question for information about how to set your path in powershell.

For example, if you want to be able to run batch files in the C:\dev\yii-1.1.9.r3527\framework directory, you can say $env:Path = $env:Path + ";C:\dev\yii-1.1.9.r3527\framework".

Or, as mloskot says, you can just add the current directory to your path, though that can pose a minor security risk. See e.g. this question for a bit of discussion on that.

4

this is an old question, but I stumbled on it looking for something else. Powershell requires you to type .\ to run commands in the current by design. https://blogs.technet.microsoft.com/csps/2010/06/06/introduction-to-windows-powershell-scripting/

2

I don't have PowerShell to try this out, but if you set the path to include current folder, this should work:

$env:Path = $env:Path + ";."
1
  • Or just $Env:Path += ';.'.
    – Joey
    Jul 31, 2013 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.