shell exec - How to run cmd commands as administrator from php -
i trying learn php shell_exec() function believe, enables run cmd commands within php script.but in system, when open command prompt , type in command, example, ipconfig
, says :
'ipconfig' not recognized internal or external command, operable program or batch file.
so in order avoid it, have right click command prompt , select "run administrator" , works fine.
now problem when try run similar commands ipconfig
inside php script, same error given above. there way solve problem? mean there way run cmd commands administrator inside php?
i attaching sample code below, can edit , me out. in advance.
here's code :
<?php $output = shell_exec('ipconfig 2>&1'); echo $output; ?>
output (which wish avoid)
'ipconfig' not recognized internal or external command,operable program or batch file.
right click command prompt , select "run administrator"
i assume using xampp , defualt install location. if not serach file php.exe , use full path.
c:\xampp\php\php.exe full\path\file.php
hence can run php script admin privilege.
Comments
Post a Comment