cmd - php -> shell_exec() -> psexec -> my executable chain fails

693

I have aphp from where I have to call acmd, and from that cmd I have to start an exe usingpsexec. Myphp,cmd,psexec.exe and theexe I actually need to run are in the same folder.

php:

shell_exec("runas.cmd");

runas.cmd:

@echo off
psexec -u userName -p password my.exe

If I run thephp I can see in the task manager thatPSexex.exe is stared butmy.exe is not. Also if I runrunas.cmd by double-clicking on it, everything is just fine.

518

Answer

Solution:

add 2>&1 after the command and print shell_exec response to see whats actually happen

$a = shell_exec('runas.cmd 2>&1');
var_dump($a);

People are also looking for solutions to the problem: javascript - Editable datas on button click

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.