$cs.Ini_WriteEntry
Description
Section titled “Description”Writes or updates a value in an INI file’s section. If the INI file (or its parent folder) doesn’t exist yet, it is created automatically.
Syntax
Section titled “Syntax”$cs.Ini_WriteEntry(string filepath, string section, string variable, string value)
Parameters
Section titled “Parameters”filepath (String)
Section titled “filepath (String)”Path to the INI file. Created automatically, along with its parent folder, if it doesn’t already exist.
section (String)
Section titled “section (String)”Section in the INI file to write to.
variable (String)
Section titled “variable (String)”Variable under the section to create or update.
value (String)
Section titled “value (String)”Value to write.
Return value
Section titled “Return value”None
Example
Section titled “Example”Disable an application’s built-in update check after installation:
$iniFile = "$env:ProgramData\Contoso\App\app.ini"$cs.Ini_WriteEntry($iniFile, "updates", "checkForUpdates", "false")Write a first-run marker for the PowerPack itself, in a config file that is created on demand:
$stateFile = Join-Path $env:ProgramData "Contoso\App\state.ini"$cs.Ini_WriteEntry($stateFile, "deployment", "firstRunCompleted", "true")$cs.Job_WriteLog("First-run marker written to $stateFile")Update a version string in a config file after a successful upgrade:
$iniFile = Join-Path $env:ProgramData "Contoso\App\settings.ini"$cs.Ini_WriteEntry($iniFile, "app", "installedVersion", $global:AppRelease)$cs.Job_WriteLog("Recorded installed version $global:AppRelease in $iniFile")