Skip to content

Robust VBScript functions to **read from** and **overwrite values** in `.ini` files, supporting any kind of file encoding. Most of the code is a collection of snippets that have been modified and assembled together. :)

Notifications You must be signed in to change notification settings

NaftaliProjects/vbs-.ini-file-Handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

vbs iniHandler

About

Robust VBScript functions to read from and overwrite values in .ini files, supporting any kind of file encoding.
Most of the code is a collection of snippets that have been modified and assembled together. :)

Requirements

  • VBScript (VBS) only

Project Structure

This project includes two files:

  1. getFileEncoding.vbs
    Determines the file's encoding type.
    (Logic adapted from Rob van der Woude’s script and turned into a function that returns the correct parameter for OpenTextFile().)

  2. iniHandler.vbs
    Provides two functions:

    • WriteToIni(path, section, key, newValue)
    • readFromIni(path, section, key)

How to Use

  1. Copy both files into your working directory.

  2. In your script, use the following to include the functions:

    '--------------------------
    ' Import other functions
    Sub Include(strFile)
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objTextFile = objFSO.OpenTextFile(strFile, 1)
        ExecuteGlobal objTextFile.ReadAll
        objTextFile.Close
        Set objFSO = Nothing
        Set objTextFile = Nothing
    End Sub
    
    ' Include handlers
    Include("iniHandler.vbs")
    '--------------------------
  3. Example usage:

    value = readFromIni("file.ini", "section", "key")
    WriteToIni("file.ini", "section", "key", "newValue")

Notes

  • Currently does not support appending new sections or keys. This may be added in the future.

Enjoy! 😃

References

About

Robust VBScript functions to **read from** and **overwrite values** in `.ini` files, supporting any kind of file encoding. Most of the code is a collection of snippets that have been modified and assembled together. :)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published