(view source code of kixini.vbs as plain text)
Option ExplicitDim blnWriteDim objFSO, objKiXtart, objScript, wshShellDim strAction, strINI, strKey, strScript, strSection, strTemp, strValue' Parse command lineWith 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
ElseblnWrite = False
End If
End With
' Get %TEMP% pathSet wshShell = CreateObject( "Wscript.Shell" )
strTemp = wshShell.ExpandEnvironmentStrings( "%TEMP%" )
Set wshShell = Nothing
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
With objFSO ' Check if specified INI file existsIf Not .FileExists( strINI ) Then
Set objFSO = Nothing
Syntax
End If
' Create temporary KiXtart scriptstrScript = .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 objectOn Error Resume Next
Set objKiXtart = CreateObject( "KiXtart.Application" )
'If Err Then Syntax TrueOn Error Goto 0
' Run temporary KiXtart scriptWith 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 strMsgstrMsg = "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
page last modified: 2025-10-11; loaded in 0.0066 seconds