Sets the value of a profile entry in an initialization file.


An empty string, upon successful execution; otherwise, an error message.


ColdFusion 11: Added the encoding parameter.


System functions

Function syntax

SetProfileString(iniPath, section, entry, value, encoding)

See also






Absolute path of initialization file


Section of the initialization file in which the entry is to be set


Name of the entry to set


Value to which to set the entry

encoding Encoding of the initialization (ini) file. For instance "UTF-8"


<h3>SetProfileString Example</h3>
This example uses SetProfileString to set the time-out value in an
initialization file. Enter the full path of your initialization
file, specify the time-out value, and submit the form.
<!--- This section checks whether the form was submitted. If so, this
section sets the initialization path and time-out value to the
path and time-out value specified in the form --->
<cfif Isdefined("Form.Submit")>

<cfset IniPath = FORM.iniPath>
<cfset Section = "boot loader">
<cfset MyTimeout = FORM.MyTimeout>
<cfset timeout = GetProfileString(IniPath, Section, "timeout")>

<cfif timeout Is Not MyTimeout>
<cfif MyTimeout Greater Than 0>
<hr size = "2" color = "#0000A0">
<p>Setting the time-out value to <cfoutput>#MyTimeout#</cfoutput>
<cfset code = SetProfileString(IniPath,
Section, "timeout", MyTimeout)>
<p>Value returned from SetProfileString:
<hr size = "2" color = "red">
<p>The time-out value should be greater than zero in order to
provide time for user response.</p>
<hr size = "2" color = "red">
<p>The time-out value in your initialization file is already
<cfset timeout = GetProfileString(IniPath, Section, "timeout")>
<cfset default = GetProfileString(IniPath, Section, "default")>

<h4>Boot Loader</h4>
<p>The time-out is set to: <cfoutput>#timeout#</cfoutput>.</p>
<p>Default directory is: <cfoutput>#default#</cfoutput>.</p>


<form action = "setprofilestring.cfm">
<hr size = "2" color = "#0000A0">
<table cellspacing = "2" cellpadding = "2" border = "0">
<td>Full Path of Init File</td>
<td><input type = "Text" name = "IniPath"
value = "C:\myboot.ini"></td>
<td><input type = "Text" name = "MyTimeout" value = "30"></td>
<td><input type = "Submit" name = "Submit" value = "Submit"></td>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy