views:

33

answers:

3

I am working on Windows server and able to run command from command prompt

c:> %convertxls% {some args....}   

But when I run same command from php script

*shell_exec(%convertxls% ..... 2>&1);*

it gives me error as

%convertxls% is not recognized as an internal or external command, operable program or batch file.

I think when I am running command from command prompt, it run for user which logged in. And when I run the php script it run for "www" user for which path is not set.

Can anybody tell me where I am doing mistake?

*Note: I haven't written complete command.

+1  A: 

Supply the full path to the executable.

Ignacio Vazquez-Abrams
A: 

ignacio right,I wanted to add one more point that ignacio did not specify .

Check the parameter disable_functions in the php.ini .

maybe this function is not allowed.

Haim Evgi
A: 

This sounds like the environment variable %convertxls% is not set.

You can use putenv() to set it; alternatively, as Ignacio already says, specify the full path.

Pekka
Thanks I have set convertxls using putenv() and its working correctly. But when I am using full path its not working and gives error 'C:/Program' is not recognized as an internal or external command, operable program or batch file.Any ways My work is done thanks once again.
Kamlesh Bhure
@Kamlesh You need to set the path in quotes. `"C:\Program Files\..."`
Pekka
note you might want to use single quotes not double quotes as using doubles means the backslash will be used a delimiter and lead to confusing errors
nathan