方法一(DOS命令):
先写到一个空的文件当中
然后 type tmpfile >>c:\autoexec.bat方法二:
Private Sub Command2_Click()
    Dim intHandle As Integer
    Dim newData As String
    intHandle = FreeFile
    
    Open "c:\temp\TESTFILE" For Binary As #intHandle
    
    newData = vbCrLf _
                & "echo hello" & vbCrLf _
                & "dir"
    Put #intHandle, LOF(intHandle), newData
    Close #intHandle
End Sub