环境变量对于批处理文件(CakePHP 中的 cake.bat)不起作用(Win 7)
我正在开始使用 CakePHP,并且尝试将 Windows 7(64 位)环境变量 PATH 设置为在使用命令提示符时在任何位置识别 C:\xampp\htdocs\cakeblog\cake\console\cake.bat 。
我已经为 php.exe 设置了环境 PATH 变量,并且运行良好。但是我在设置的时候,把路径添加到系统变量后,并没有起作用。由于某种原因,我必须将其添加到用户变量中才能使其正常工作。我不知道为什么会这样。
我尝试对“C:\xampp\htdocs\cakeblog\cake\console”执行相同的操作,但由于某种原因它在系统或用户变量中都不起作用。我正在重新启动命令提示符以使更改广播生效,但它仍然不起作用,尽管它适用于 php.exe。 .bat 文件的处理方式不同吗?我无法启动 CakePHP 烘焙过程!
知道如何包含此路径以便我可以访问 cake.bat 吗?创建另一个 .bat 文件(如 runcake.bat)来直接运行 C:\xampp\htdocs\cakeblog\cake\console\cake.bat 不是一个选项,因为 cake.bat 在相对于其运行位置的文件夹中创建文件。因此,如果我转到 C:\xampp\htdocs\cakeblog\cake\console\ 并运行 cake.bat,它会尝试将文件创建为 C:\xampp\htdocs\cakeblog\cake\console 作为其根目录,当我真的希望将文件创建在 C:\mysite..TIA 之类的地方!
我的用户路径如下。 cake.bat 位于第二个目录中。
C:\xampp\php; C:\xampp\htdocs\cakeblog\cake\console
更新: 我刚刚放弃了这种方法,只编写了一个名为 setpaths.bat 的短批处理文件,其中包含“set path=C:\xampp\htdocs\cakeblog\cake\console;C:\xampp\php”。这似乎覆盖了我的用户路径变量并且效果很好。每次我需要烘焙一些东西时,我只需要运行 setpaths.bat 即可。
I'm getting started with CakePHP, and I'm trying to set my Windows 7's (64-bit) environmental variable PATH to recognize C:\xampp\htdocs\cakeblog\cake\console\cake.bat anywhere when using the command prompt.
I have set the environmental PATH variable for php.exe, and it is working great. However, when I was setting it, it didn't work when I added the path to the system variable. I had to add it to the user variable for it to work for some reason. I have no clue why this is so.
I tried doing the same for "C:\xampp\htdocs\cakeblog\cake\console," but it doesn't work for some reason neither in the system or user variable. I'm restarting the command prompt for the change broadcast to take effect, but it still doesn't work, while it works for php.exe. are .bat files different handled or something? I can't start the CakePHP baking process!
Any idea how to get this path included so that I can access cake.bat? Creating another .bat file (like runcake.bat) to directly run C:\xampp\htdocs\cakeblog\cake\console\cake.bat is not an option, as cake.bat creates files in the folder relative to where it's run. So, if I go to C:\xampp\htdocs\cakeblog\cake\console\ and run cake.bat, it will try to create files as C:\xampp\htdocs\cakeblog\cake\console as its root directory when I really want the files to be created somewhere like C:\mysite.. TIA!
My user path is below. cake.bat is located in the second directory.
C:\xampp\php; C:\xampp\htdocs\cakeblog\cake\console
UPDATE:
I just gave up with this approach and just wrote a short batch file named setpaths.bat that includes "set path=C:\xampp\htdocs\cakeblog\cake\console;C:\xampp\php" in it. This seems to override my user path variable and works great. I'll just have to run setpaths.bat every time I need to bake something.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在我的例子中,分号后面的空格是问题所在。
A space after the semi-colon was the problem in my case.
确保它位于 Path 变量中,尝试删除分号和下一个路径之间的任何空格。只是一个疯狂的猜测。
Make sure it's in the Path variable, try removing any spaces between semicolon and the next path. Just a wild guess.
由于某种原因,我的 Windows 7 环境路径变量无法正常工作。我在我的家用计算机(相同的操作系统)上做了同样的事情,而且效果很好。我刚刚在工作计算机上放弃了这种方法,只编写了一个名为 setpaths.bat 的短批处理文件,其中包含“set path=C:\xampp\htdocs\cakeblog\cake\console;C:\xampp\php” 。这似乎覆盖了我的用户路径变量并且效果很好。不过,.bat 文件需要在每个会话期间运行。希望这可以帮助其他可能遇到类似问题的人。
My Windows 7 environmental path variable is not working correctly for some reason. I have done the same thing on my home computer (same OS), and that one works just fine. I just gave up with this approach on my work computer and just wrote a short batch file named setpaths.bat that includes "set path=C:\xampp\htdocs\cakeblog\cake\console;C:\xampp\php" in it. This seems to override my user path variable and works great. The .bat file needs to be run during each session though. Hope this helps someone else who might be having a similar problem.