pelcomppl
pelcomppl

Reputation: 575

Php exec - not work with parameters

I need to use exec() function, but it doesn't work with params.

It works:

exec('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe');

It doesn't:

exec('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --headless --disable-gpu --screenshot=D:\file211.png --window-size=1920,1200 http://google.com')

What to do to set params in exec?

Upvotes: 2

Views: 425

Answers (1)

Dukecz
Dukecz

Reputation: 362

http://php.net/manual/en/function.exec.php:

Note: On Windows exec() will first start cmd.exe to launch the command. If you want to start an external program without starting cmd.exe use proc_open() with the bypass_shell option set.

You can also use popen() instead of proc_open():

$handle = popen('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --headless --disable-gpu --screenshot=D:\file211.png --window-size=1920,1200 http://google.com', 'r');

...

Upvotes: 1

Related Questions