Search code examples
phpshell-execwmic

php shell_exec WMIC remote computer on the network


i'm trying to get information about remote pc on the network , like serial number , computer model etc.. and i try the following commend on php ,but it's not work.

please help

Note : when i use it on CMD and it's work fine ,also when i test the local ip address on the same code it's work fine

<?php 
$pcname = "test-pc";
$test=shell_exec("C:\\Windows\\System32\\wbem\\WMIC.exe /NODE:". $pcname." COMPUTERSYSTEM GET USERNAME");
?>
   

also the i try the following code as well

$test=shell_exec("WMIC /NODE:". $pcname." COMPUTERSYSTEM GET USERNAME");


Solution

  • i found the solution , when you want to exec WMIC on php to get information about remote pc you have to mention domain username and password ,as you can see below ,

    $test1=shell_exec('wmic /USER:"domain\username1"  /PASSWORD:"password1"  /NODE:"test-pc"   COMPUTERSYSTEM GET USERNAME');
    echo $test1;