Trying to write a php page that has a form that lets you type in a remote IP or Hostname, and retrieve basic info like RAM Size and HD size.
The code that processess the form data:
$host = $_POST['host'];
$cmd = "cscript /nologo remotehostinfo.vbs ".$host;
$output = shell_exec($cmd);
echo "<pre>$output</pre>";
This is the remotehostinfo.vbs code, the script does a WMI query to a remote host.
DIM arg
Set arg = wscript.Arguments
strComputer = arg(0)
On Error Resume Next
wscript.echo "Info"
wscript.echo "------"
'//////// Get Ram Amount
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colCSItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objCSItem In colCSItems
ram = int(objCSItem.TotalPhysicalMemory/ 1048576)
Next
wscript.echo "RAM Size: " & ram
wscript.quit
When I run the script from the PHP page, it does not return the RAM size, but if I run the vb script from a command prompt it works just fine, anyone know what I'm doing wrong? Can PHP not run a vbscript that does a query of a remote host?