Change current working directory from batch file a

2019-07-20 12:23发布

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 ?

3条回答
做自己的国王
2楼-- · 2019-07-20 12:43

you might try this:

start "" /d "w:\folder" /b "p:\php\php.exe" file.php
查看更多
倾城 Initia
3楼-- · 2019-07-20 12:53

This may also work:

@echo off
cd /d "w:\folder"
"p:\php\php.exe" "file.php"
查看更多
Summer. ? 凉城
4楼-- · 2019-07-20 13:00

this is how I solved the problem, try this:

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

this seems to work.

查看更多
登录 后发表回答