pryashrma
pryashrma

Reputation: 102

Execute multiple windows cmd commands and store process result

I want to write a php code to automate the below mentioned process.

Process in Windows Command prompt for each file:

  1. Go to specific folder say "x", by "cd x's folder path"
  2. Run command run-all.bat RelativePath+filename.php
  3. Analysis the result produced.

I have around thousand's of files and if I do it manually then it will take a while. I took folder path input from the user, then accessed each file.

To execute the command, used exec function of php, but don't know how to specify "cd folder path and run-all.bat" in a single line, as if we are not inside the specific folder "x" the command run-all will not be executed.

For the third step, I think the somehow array output (second parameter can be used).

Any help/suggestion are appreciated as I'm a newbie to php?

Upvotes: 2

Views: 136

Answers (1)

Jelle Keizer
Jelle Keizer

Reputation: 721

guess this is what you are looking to accomplish ?

exec ('c:\\somefolder\\run-all.bat RelativePath\\filename.php', $output);

Upvotes: 2

Related Questions