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?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
dragonfly
  • 17,407
  • 30
  • 110
  • 219

3 Answers3

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/

Zack
  • 2,291
  • 2
  • 23
  • 38
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.

Community
  • 1
  • 1
David
  • 987
  • 1
  • 7
  • 14
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 + ";."
icyrock.com
  • 27,952
  • 4
  • 66
  • 85