ColdFusion System Properties...

I recently needed to use ColdFusion to determine some properties of the operating system. This is easily done with the following code:

<cfset sysObj = CreateObject("java","java.lang.System") />
<cfset tmpOSProps = sysObj.getProperty("os.name") />

The getProperty() method is used to access several of the system properties. The parameter sent is the key to the property you want to access. A list of keys can be found on Sun's web site.

It should be noted that if you are in a shared hosting environment, you may not be able to use the CreateObject() method. Thus, you will not be able to access the java objects.

Comments
Contact Chris SchofieldBlogCFC was created by Raymond Camden. This blog is running version 5.9.001.