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

598 views Asked by At

I have a php from where I have to call a cmd, and from that cmd I have to start an exe using psexec. My php, cmd, psexec.exe and the exe 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 the php I can see in the task manager that PSexex.exe is stared but my.exe is not. Also if I run runas.cmd by double-clicking on it, everything is just fine.

1

There are 1 answers

15
SkyFox On BEST ANSWER

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);