Option Explicit Dim blnWrite Dim objFSO, objKiXtart, objScript, wshShell Dim strAction, strINI, strKey, strScript, strSection, strTemp, strValue ' Parse command line With WScript.Arguments If .Named.Count > 0 Then Syntax If .Unnamed.Count < 3 Then Syntax If .Unnamed.Count > 4 Then Syntax strINI = .Unnamed(0) strSection = .Unnamed(1) strKey = .Unnamed(2) If .Unnamed.Count = 4 Then strValue = .Unnamed(3) blnWrite = True Else blnWrite = False End If End With ' Get %TEMP% path Set wshShell = CreateObject( "Wscript.Shell" ) strTemp = wshShell.ExpandEnvironmentStrings( "%TEMP%" ) Set wshShell = Nothing Set objFSO = CreateObject( "Scripting.FileSystemObject" ) With objFSO ' Check if specified INI file exists If Not .FileExists( strINI ) Then Set objFSO = Nothing Syntax End If ' Create temporary KiXtart script strScript = .BuildPath( strTemp, "_ReadINI.kix" ) Set objScript = .CreateTextFile( strScript, True, False ) objScript.WriteLine "If $Write" objScript.WriteLine vbTab & "$RC = WriteProfileString( $INIFile, $INISection, $INIKey, $INIValue )" objScript.WriteLine "EndIf" objScript.WriteLine "$RC = ReadProfileString( $INIFile, $INISection, $INIKey )" objScript.Close Set objScript = Nothing End With ' Create KiXtart object On Error Resume Next Set objKiXtart = CreateObject( "KiXtart.Application" ) 'If Err Then Syntax True On Error Goto 0 ' Run temporary KiXtart script With objKiXtart .SetVar "INIFile", strINI .SetVar "INISection", strSection .SetVar "INIKey", strKey If blnWrite Then .SetVar "INIValue", strValue .SetVar "Write", True Else .SetVar "Write", False End If .RunScript strScript strValue = .GetVar( "RC" ) End With Set objKiXtart = Nothing WScript.Echo strValue Sub Syntax( ) Dim strMsg strMsg = "KixINI.vbs, Version 1.00" & vbCrLf _ & "Use KiXtart COM object to read or write INI files" & vbCrLf & vbCrLf _ & "Usage:" & vbTab & "KIXINI.VBS INIFile INISection INIKey [ INIValue ]" & vbCrLf & vbCrLf _ & "Where:" & vbTab & "INIFile, INISection and INIKey are the INI file, section and key" & vbCrLf _ & vbTab & "respectively." & vbCrLf _ & vbTab & "INIValue is the optional new value; if it is specified, it will be" & vbCrLf _ & vbTab & "written to, otherwise the value will be read from the INI file." & vbCrLf & vbCrLf _ & "Notes:" & vbTab & "The script can read, write and create values, but not delete them." & vbCrLf _ & vbTab & "KIXTART.DLL must be registered for this script to work." & vbCrLf & vbCrLf _ & "Written by Rob van der Woude" & vbCrLf _ & "http://www.robvanderwoude.com" WScript.Echo strMsg WScript.Quit 1 End Sub