-1

I have used this article php script which named upload_.php and i have successfully developed a windows service in C# which is running fine. Now in theory the service will run every hour and execute a batch file (task.bat). if i run the upload_php file directly it works fine now i think the problem is in task.bat file. here is my code

Task.bat Code

@echo off
cd\
set path=C:\xampp\php;
cd "C:\xampp\htdocs"
php import.php
exit

When service runs it execute task.bat file but php script dont execute. what is wrong with my code????

6
  • You should be seeing an error message. (@Sverri Apache shouldn't be needed here) Commented Feb 7, 2013 at 11:56
  • Reference: php.net/manual/en/features.commandline.php (but you seem to be doing everything right) Commented Feb 7, 2013 at 11:57
  • 1
    I have no idea about MS-Windows, but doesn't it (whyever) require all executables to be called *.exe? So php.exe in this case instead of just php? Commented Feb 7, 2013 at 11:58
  • is space missing first cd so rather than cd\ you need cd \? When you run the batch file by hand do you see error message? try running .bat file in a console window and remove the echo off so you can see what happens then let us know. Commented Feb 7, 2013 at 11:59
  • i'm able to see that you are running import.php in your tasks.bat instead upload_.php.. am i right ? Commented Feb 7, 2013 at 12:04

1 Answer 1

4

this worked for me although im not a php developer a colleague helped me

@echo OFF
"D:\xampp\php\php.exe" D:\xampp\htdocs\upload_.php %*
Sign up to request clarification or add additional context in comments.

1 Comment

So the problem was that your path and change directory were both specifying the wrong drive letter because your php was installed on the D: drive and not the C: drive? And you were specifying arguments to the .bat file which needed to be provided to the php script and your use of the php command was not providing those?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.