'************************************************
' File:    TestFile.txt (WSH sample in VBScript) 
' Author:  (c) G. Born
'
' Appending a line to a text file
'************************************************
Option Explicit

Const file1 = "C:\Autoexec.xx1"

Const ForAppending = 8  ' Must be defined

Dim Text
Dim fso                 ' Object variable
Dim txtStream           ' Text stream

' Create a FileSystemObject object to access the file system.
Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FileExists(file1) Then  ' Check whether the file exists.
    Set txtStream = fso.OpenTextFile(file1, _
            ForAppending)      ' Output file

    txtStream.WriteLine "Set Born=Hello" ' Append line.

    Set txtStream = Nothing    ' Release object.
    WScript.Echo "Text file " & file1 & " extended."
Else
    WScript.Echo "File " & file1 & " not found."
End If

WScript.Quit         ' Terminate script.

'*** End
