i would agree with the XML comment in general, it is a great new skill to have.
however i would temper this that for simlpe key and value data an ini file is easier to read, this is important for things like logon scripts as you want people in other locations to be able to manage it and ask them to read xml and they will pee their pants.
i use this to read ini files, it returns a dictionary object of dictionary objects.
the root dic object is the ini file, each dictionary contained in that represents an ini file section and its key and values:
Set dicGlobal = ParseAllINI(str2inifile)
'then something like
Wscript.Echo dicGlobal.Item("INI_SECTION_NAME").Item("key_name")
'would give you the #VALUE of
'[INI_SECTION_NAME}
'key_name=#VALUE
Function ParseAllINI(strIniFileName)
On Error Resume Next
Dim ParseAINI, blnFoundSection, strSection
Dim intEquals, sKey, sVal, i, sLine, tsIni
blnFoundSection = False
Err.Clear
If FSO.FileExists(strIniFileName) Then
Set tsIni = FSO.OpenTextFile(strIniFileName)
Set ParseAllINI = WScript.CreateObject("Scripting.Dictionary")
Do While Not tsIni.AtEndOfStream
sLine = ""
sLine = Trim(tsIni.ReadLine)
If sLine <> "" Then
If Left(sLine,1) <> ";" Then
If Left(sLine,1) = "[" Then
blnFoundSection = True
'Msgbox sLine & " section found"
strSection = Left(sLine, Len(sLine) - 1)
strSection = Right(strSection, Len(strSection) - 1)
Set ParseAINI = Wscript.CreateObject("Scripting.Dictionary")
ParseAllINI.Add UCase(strSection), ParseAINI
Else
'key and value logic
intEquals = InStr(1, sLine, "=")
If (intEquals <= 1) Then
'msgbox "error: the following line is invalid " & sLine
Else
'weve found a valid line
sKey = Left(sLine, intEquals - 1)
sVal = Right(sLine, Len(sLine) - intEquals)
Err.Clear
ParseAINI.Add Trim(LCase(sKey)), Trim(sVal)
If Err.Number <> 0 Then
'msgbox "unable to add to dictionary object"
End If
'msgbox strSection & " " & sKey & ";;;;" & sVal
'key and value logic end if
End If
End If
End If
End If
Loop
tsIni.Close
Set tsIni = Nothing
If blnFoundSection = False Then
Set ParseAllINI = Wscript.CreateObject("Scripting.Dictionary")
End If
Else
Set ParseAllINI = Wscript.CreateObject("Scripting.Dictionary")
End If
End Function
'i used it to have a [MAPDRIVE], [MAPPRINTER] etc section.
on top of that i had the fact that one could have an ini file for each office location (luckily all our PC's had a registry key which stated where their 'HomeLocation' was from) so when they logon read the HomeLocation from the registry and then you know to read a specific ini file, ontop of that read their 'CurrentLocation' from AD site info and then you can load another ini file. ontop of that i had it so that you could have an ini for an AD group, or an AD user, so you could have lots of ini files to read at logon. all this was hirachecal where userINI was the most powerful and Location was the least so you could override settings when you wanted to.
anyway i go on,