Ank
Ank

Reputation: 6270

php command line on windows

I'm using php on WAMP. I'm trying to run an external program prog.exe under directory abc which takes one numeric parameter. the following command on DOS command line works fine

c:\abc\prog.exe 1234

but when I do it in php script it doesn't run.

$val="1234";
$comm = passthru("C:\abc\prog.exe ".$val)

but

$comm = passthru("dir");
echo $comm; 

works fine.

I'm running Windows 7.

P.S I've also tried system() and shell_exec()

Upvotes: 0

Views: 1068

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324640

\ needs to be escaped as \\, or else you should use single quotes.

EITHER:

passthru("C:\\abc\\prog.exe ".$val);

OR:

passthru('C:\abc\prog.exe '.$val);

Upvotes: 3

Related Questions