# IniWrite

Writes a value to a standard format .ini file.

    IniWrite, Value, Filename, Section [, Key]

### Parameters

Value | The string or number that will be written to the right of Key's equal sign (=). If the text is long, it can be broken up into several shorter lines by means of a continuation section, which might improve readability and maintainability. [AHK_L 57+]: If Key is omitted, this parameter should contain the complete content of a section to write to the .ini file, excluding the [SectionName] header.
Filename | The name of the .ini file, which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.
Section | The section name in the .ini file, which is the heading phrase that appears in square brackets (do not include the brackets in this parameter).
Key | The key name in the .ini file.

### ErrorLevel

[v1.1.04+] This command is able to throw an exception on failure. For more information, see Runtime Errors.

ErrorLevel is set to 1 if there was a problem or 0 otherwise.

### Remarks

A standard ini file looks like:

    [SectionName]
    Key=Value

Unicode: IniRead and IniWrite rely on the external functions GetPrivateProfileString and WritePrivateProfileString to read and write values. These functions support Unicode only in UTF-16 files; all other files are assumed to use the system's default ANSI code page. In Unicode scripts, IniWrite uses UTF-16 for each new file. If this is undesired, ensure the file exists before calling IniWrite. For example:

    FileAppend,, NonUnicode.ini, CP0 ; The last parameter is optional in most cases.

### Related

IniDelete, IniRead, RegWrite

### Example

    IniWrite, this is a new value, C:\Temp\myfile.ini, section2, key