Does anybody know of a way to retrieve information about the manufacturer/model of the device that the AIR app is running on. The Capabilities class doesn\'t seem to cut it.
On Windows, it's possible to query the motherboard's serial number with WMIC, or Windows Management Instrumentation Command-line. Therefore, you can simply pass the command wmic baseboard get serialnumber as an argument to cmd.exe using flash.desktop.NativeProcess without the need for a Native Extension.
Since the AIR NativeProcess API is being used, you must use the Extended Desktop
application profile and package your application with a native installer.
package
{
//Imports
import flash.display.Sprite;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.desktop.NativeProcess;
import flash.desktop.NativeProcessStartupInfo;
import flash.events.ProgressEvent;
import flash.filesystem.File;
//Class
[SWF(width = "600", height = "250", frameRate = "60", backgroundColor = "0x000000")]
public class Main extends Sprite
{
//Constants
private static const MOTHERBOARD_SERIALNUMBER_COMMAND:String = "wmic baseboard get serialnumber";
//Properties
private var nativeProcess:NativeProcess;
//Constructor
public function Main():void
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
init();
}
//Init
private function init():void
{
if (!NativeProcess.isSupported)
{
throw new Error("Native Process is not supported.");
}
var file:File = new File("C:\\Windows\\System32\\cmd.exe");
var args:Vector.<String> = new Vector.<String>();
args.push("/c");
args.push(MOTHERBOARD_SERIALNUMBER_COMMAND);
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
nativeProcessStartupInfo.executable = file;
nativeProcessStartupInfo.arguments = args;
nativeProcess = new NativeProcess();
nativeProcess.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, outputDataEventHandler);
nativeProcess.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, outputErrorEventHandler);
nativeProcess.start(nativeProcessStartupInfo);
}
//Output Data Event Handler
private function outputDataEventHandler(event:ProgressEvent):void
{
var output:String = nativeProcess.standardOutput.readUTFBytes(nativeProcess.standardOutput.bytesAvailable);
nativeProcess.exit();
trace(output);
}
//Output Error Event Handler
private function outputErrorEventHandler(event:ProgressEvent):void
{
nativeProcess.exit();
throw new Error(event);
}
}
}
[EDIT]
Alternatively, if you would also like to retreive the motherboard's manufacturer, model number and serial number, you can update the string constant to this:
//Constants
private static const MOTHERBOARD_INFO:String = "wmic baseboard get product, manufacturer, serialnumber";
[EDIT 2]
I just learned that the following WMIC command will return the name, vendor and identifying number of a machine. It sounds exactly what your looking for:
//Constants
private static const CSPRODUCT_INFO:String = "wmic csproduct get name, vendor, identifyingNumber";
However, keep in mind that for custom built PCs, such as my own, this command returns nothing. Well, not exactly nothing, but instead of something typical like:
IdentifyingNumber Name Vendor
99L9891 Latitude D610 Dell Inc.
My custom build returns this:
IdentifyingNumber Name Vendor
System Serial Number System Product Name System manufacturer