0

I am actually writing a little PHP script, in order to retrieve files in folder on a FTP server and download them locally. Another script put those file in the server.

So here's my question : how can I write a batch file that will execute the first php script, then run a program (a game in this case). When the game is closed, execute the second script.

So it will be this process :

  1. When run the batch file, execute the first script (get file)
  2. When all files are downloaded, run the programm (game.exe)
  3. After game closing, execute the second script (put file)

I think at a .bat file, but maybe there is an another solution.

Thanks is advance ! Telest.



EDIT : Thanks for your answer.

Google gives me this post : How to wait for a process to terminate to execute another process in batch file. I found that I can use /W in order to wait the program ends.

But /W seems not working. Tried /WAIT but no success.

Here is my batch file :

PHP C:\Users\PHProjects\test1.php
START /WAIT /B chrome.exe
PHP C:\Users\PHProjects\test2.php
PAUSE

(test1.php & test2.php are just dummy echo).

And the console result :

Chrome executes well, but test2 too

As you can see, Chrome executes well, but so do test2.php.

Is something wrong here ?

Thanks.

Community
  • 1
  • 1
Telest
  • 27
  • 7
  • Using `.bat` file you could add something like `c:\path\to\php.exe -f "c:/path/to/script.php"`. – cwps Dec 19 '15 at 16:57

2 Answers2

0
call getfile.bat
start "" /w game.exe
call putfile.bat

see start /? and call /?. With start take note of the second half which details how not using start works (confusing I know}. Call details, as start details for programs, how it works calling a batch directly versus call.

bgalea
  • 67
  • 2
0

I updated my first post with new elements.

Telest
  • 27
  • 7