Change current working directory from batch file and run script

感情迁移 提交于 2019-12-24 02:03:49

问题


In Windows 8: I have a php file which needs to be run from the scheduled tasks through .bat file. The PHP is located in: P:\php\php.exe The file to run is located in: W:\folder\file.php

my .bat file looks like this:

cmd /c p:\php\php.exe w:\folder\file.php

It does not run. When I open cmd and switch to the file folder and run it from there, the file executes properly.

i.e.: W:\folder> p:\php\php.exe w:\folder\file.php

I have to add something to the .bat file which navigates to this w:\folder and executes it in the same manner but I cannot figure out what. I tried other posts (replies) i.e.: How to change current working directory using a batch file

but it did not take any effect. Can anyone help me to write the correct command for the .bat file please ?


回答1:


you might try this:

start "" /d "w:\folder" /b "p:\php\php.exe" file.php



回答2:


This may also work:

@echo off
cd /d "w:\folder"
"p:\php\php.exe" "file.php"



回答3:


this is how I solved the problem, try this:

cd p:\php\
p:
php.exe w:\folder\file.php

this seems to work.



来源:https://stackoverflow.com/questions/18906712/change-current-working-directory-from-batch-file-and-run-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!