Anhängen an eine Datei statt overwritting die Datei jedes mal in VBScript

Ich versuche nur, um eine log-Datei hier. Ich habe versucht, etwas zu tun mit OpenTextFile statt CreateTextFile, aber dann ist es eben schreibt nichts und ich bin wirklich nicht sicher, warum, und ich habe Probleme bei der Suche nach der info, die ich brauche.

'Nick Repella 10/29/13

'Needed in case object does not exist (outdated list)
On Error Resume Next

Function IsCompDisabled(strLine)
    Dim objComputer
    objComputer = "LDAP://cn="
    objComputer = objComputer & strLine
    objComputer = objComputer & ",ou=HIDDENOU,dc=HIDDENDC,dc=HIDDENDC,dc=HIDDENDC"
    IsCompDisabled = GetObject(objComputer).AccountDisabled
End Function 

'Set the file to read computer names from (Change C:\scripts\text.txt to the 
'target file)
Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\scripts\text.txt", 1)

Dim strLine

Do While Not objFileToRead.AtEndOfStream
    strLine = objFileToRead.ReadLine()
    If (IsCompDisabled(strLine) = True) Then
        outFile="c:\scripts\compDisableCheck.log"
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objFile = objFSO.CreateTextFile(outFile, True)
        objFile.Write strLine & "has been deleted"
        objFile.Close        
    Else
        WScript.Echo strLine & " computer is enabled no action taken"
    End If
Loop

MsgBox "Done"

InformationsquelleAutor user2939192 | 2013-10-30

Schreibe einen Kommentar