Getting System/OS information in Coldfusion

This Article describe how to get the follwoing system information in Coldfusion using .Net OS Information

  • Hard Disk Information
  • IP and Computer Name
  • Mac Address
  • Computer information

Steps to follow

Create a Class Library in .Net and compile and get the dll file generated from .Net

Call the dll from coldfusion and access the methods from dll

.Net Code Snippets

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Collections;
using System.Data;
using System.Net;
using System.Text;
using System.Management;
public class OSinformation
// Method to get the HardDisk Informationpublic DataTable GetDriveInfo()
ManagementObjectSearcher query1 = new ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk");
ManagementObjectCollection queryCollection1 = query1.Get();
DataTable DT = new DataTable();
// Add the Columns headers to the table
foreach (ManagementObject mo in queryCollection1)
// Adding the rwos to the table
DataRow drdummy= DT.NewRow();
drdummy["DeviceID"] = mo["DeviceID"].ToString();
drdummy["Description"] = mo["Description"].ToString();
drdummy["Freespace"] = Convert.ToInt64(mo["Freespace"])/ 1024/1024 + " MB";
return DT;
// Method to get the OS Information
public DataTable GetOsinfo()
ManagementObjectSearcher query2 = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
ManagementObjectCollection queryCollection2 = query2.Get();
DataTable OSDT = new DataTable();
// Add the Columns headers to the table
foreach (ManagementObject mo in queryCollection2)
DataRow drdummy = OSDT.NewRow();
drdummy["name"] = mo["name"].ToString();
drdummy["version"] = mo["version"].ToString();
drdummy["csname"] = mo["csname"].ToString();
drdummy["windowsdirectory"] = mo["windowsdirectory"].ToString();


return OSDT;

// Method to get the Computer Information
public DataTable GetCSinfo()
ManagementObjectSearcher query3 = new ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem");
ManagementObjectCollection queryCollection3 = query3.Get();
DataTable CSDT = new DataTable();

foreach (ManagementObject mo in queryCollection3)

DataRow drdummy = CSDT.NewRow();
drdummy["manufacturer"] = mo["manufacturer"].ToString();
drdummy["model"] = mo["model"].ToString();
drdummy["systemtype"] = mo["systemtype"].ToString();
drdummy["Memory"] = mo["totalphysicalmemory"].ToString();


return CSDT;

public String GetIPAndCompName()
String S22;
String ComputerName;
String IP;
ComputerName = Dns.GetHostName();
IPHostEntry ipEntry = Dns.GetHostEntry(ComputerName);
IP = ipEntry.AddressList[0].ToString();
S22 = IP + "," + ComputerName;
return S22;
/// Returns MAC Address from first Network Card in Computer
/// [string] MAC Address
public string GetMACAddress()
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
string MACAddress = String.Empty;
foreach (ManagementObject mo in moc)
if (MACAddress == String.Empty) // only return MAC Address from first card
if ((bool)mo["IPEnabled"] == true) MACAddress = mo["MacAddress"].ToString();
MACAddress = MACAddress.Replace(":", "");
return MACAddress;

/// Return processorId from first CPU in machine
/// [string] ProcessorId
public string GetCPUId()
string cpuInfo = String.Empty;
string temp = String.Empty;
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
if (cpuInfo == String.Empty)
{// only return cpuInfo from first CPU
cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
return cpuInfo;


CFM Code

type = "dotnet"
name = "MDBDTable"
class = "OSinformation"
assembly ="d:/Vishnu/OSinformation.dll">

<cfset dummy = MDBDTable.GetCSinfo()>
<cfdump var="#dummy#"><br>

<cfset dummy = MDBDTable.GetDriveInfo()>
<cfdump var="#dummy#"><br>

<cfset dummy = MDBDTable.GetOsinfo()>
<cfdump var="#dummy#"><br>

<cfset dummy = MDBDTable.GetIPAndCompName()>
<cfset IP = listgetat(dummy,1)>
<cfset domain = listgetat(dummy,2)>
IP is #IP# <br>
Domain is #domain#<br>

<cfset dummy = MDBDTable.GetMACAddress()>
Macaddress is : #dummy#

Source fot this sample can be get from the url


8 thoughts on “Getting System/OS information in Coldfusion

  1. Do u mean call sharepoint from .coldfusion?
    No UI component can be called using coldfusion and .Net integration

    call sharepoing from .Net itself?
    possible i guess

  2. Good day! This is kind of off topic but I need some advice from
    an established blog. Is it hard to set up your own blog?

    I’m not very techincal but I can figure things out pretty fast. I’m thinking about creating my own but I’m not sure where to begin. Do you have any ideas or suggestions? Thanks

  3. Throughout the years they have had been enable
    a huge number of women and men repair its a marriage along with
    miserable relationships by letting rear the love along with communication which
    the partners deficiency.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s