KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Extracting hardware attributes using Launch External Process in Windows
PRODUCT: 4D | VERSION: 13.3 | PLATFORM: Win
Published On: December 6, 2013

In order to obtain hardware attributes in a Windows machine, it is possible to utilize the Windows Management Instrumentation command-line (WMIC). 4D has the ability to call WMIC through LAUNCH EXTERNAL PROCESS.

The sample code below can extract the following:

  • Computer Product Name

  • Processor ID

  • Bios Serial Number

  • Hard Drive Serial Number


C_TEXT($in)
C_TEXT($outCPN;$outPID;$outBSN;$outHDSN) //Output of requested attribute
C_TEXT($errCPN;$errPID;$errBSN;$errHDSN) //Error of Outputs
$in:=""
SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"True") // hide console
LAUNCH EXTERNAL PROCESS("wmic csproduct get name";$in;$outCPN;$errCPN)
SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"True") // hide console
LAUNCH EXTERNAL PROCESS("wmic cpu get ProcessorId";$in;$outPID;$errPID)
SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"True") // hide console
LAUNCH EXTERNAL PROCESS("wmic bios get serialnumber";$in;$outBSN;$errBSN)
SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"True") // hide console
LAUNCH EXTERNAL PROCESS("wmic diskdrive get serialnumber";$in;$outHDSN;$errHDSN)


$errCPN - Extracts the Computer Product Name (eg: Name XPS 8512)
$errPID - Extracts the Processor ID (eg: ProcessorID BFEBFBFF142345B8)
$errBSN - Extracts the Bios serial number (eg: Serial Number 574ZVV1)
$errHDSN - Extracts the Hard Drive serial number (eg: Serial Number 215126043035)

Please note that WMIC has wide range of attributes to extract and the code above is just a sample.

A link is provided for reference:


WMIC Applies to the following Windows OS:
  • Windows XP, Vista, and 7

  • Windows Server 2003 and 2008