I am trying to get the bios serial number in PHP which will be stored as an exe through Exeoutput. Since I was not able to fetch the serial number in exeoutput, but was getting it in browser, I concluded that php files are running under a virtual directory so they cannot access hardware. I also got a suggestion that I should use VBScript to fetch the bios serial number and pass it back to php. My vbscript is as below:
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
arrComputers = Array(".")
For Each strComputer In arrComputers
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
WScript.Echo objItem.IdentifyingNumber
Next
Next
The calling php code is below:
$WshShell = new COM("WScript.Shell");
$obj = $WshShell->Run("cscript mbs.vbs", 0, true);
var_dump($obj);
On executing vbs from command prompt, I am getting the serial number but when trying to make it work through php, I get only
int(1) printed on web page.