Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 235
fishmong3r Avatar asked Apr 09 '26 10:04

fishmong3r


1 Answers

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);
like image 163
SkyFox Avatar answered Apr 11 '26 01:04

SkyFox



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!