Re: VBScript can't read NTBackup log files



Hi !

Have a look into the scripting reference:


object.OpenTextFile(filename[, iomode[, create[, format]]])

format
Optional. One of three Tristate values used to indicate the format of the opened file. If omitted, the file is opened as ASCII.


So, try:

Set LogFile=FSObj.OpenTextFile
("C:\LogTemp\backup01.log", ForReading, TristateTrue)

Regard, sometimes you must defines the constants by
yourself [use: true, -1] for above.

I am sure, NTBackup writes in Unicode, so this way should work.

Best regards,
Manfred

Ken Morley wrote:
Our company uses Windows 2003 Server and Exchange 2003, both of which are patched to the latest revision.

I would like to automate our Exchange backups. I have written a VBScript that backs up Exchange to a disk file. After the backup, I would like the script to delete the oldest backup file only if the backup was successful.

NTBackup does not return a useful exit code (see KB article 260327), so I can't use that obvious method of determining success or failure. So, I decided to open, read and parse the log files instead.

Even though the log files appear to be text files, my script returns the same three garbage characters from every NTBackup log file. I'm guessing that the characters are at the begining of the logs and Notepad just ignores them. VBScript must think they are EOF or something, because I can't read past them.

If I cut the text from a NTBackup log file and paste it into a text file, my script works fine. I've included the VBScript code demonstrating the problem below.

To complete this project, I need one of the following:

a version of NTBackup that returns a useful exit code;
a version of NTBackup that doesn't begin log files with garbage characters;
a VBScript that can read past the garbage characters;
an alternative method for determining NTBackup success/failure.

Any suggestions will be greatly appreciated!

Ken Morley
ken@xxxxxxxxxxxxxxx

* * * * * VBScript Code Follows * * * * *
Dim LogFile, FSObj
Set FSObj = CreateObject("Scripting.FileSystemObject")

' NTBackup log files are normally stored in:
' C:\Documents and Settings\Administrator.DOMAIN\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data.
' Logs were moved to C:\LogTemp for clarity.

Set LogFile=FSObj.OpenTextFile("C:\LogTemp\backup01.log")

WScript.Echo LogFile.ReadAll()

.



Relevant Pages

  • Re: VBScript cant read NTBackup log files
    ... The backup log is in UNICODE. ... Even though the log files appear to be text files, ... same three garbage characters from every NTBackup log file. ... If I cut the text from a NTBackup log file and paste it into a text file, ...
    (microsoft.public.windows.server.general)
  • Re: Recording AD Logons to SQL Database
    ... and from what pc by running the code below in my login script. ... ' Specify SQL Server, Instance name, and database. ... on demand to combine them into a single csv file. ... intervention is required in order to keep the log files to a reasonable size ...
    (microsoft.public.windows.server.scripting)
  • Re: [Info-Ingres] Setting up Ingres Security Auditing for query_text
    ... of a shell script to archive the audit files, ... refusing to restart if there is a problem in the log files. ... Register into a normal database, ... Set the audit files to be small to test file "switching". ...
    (comp.databases.ingres)
  • Re: Size of wtmp files
    ... for logrotate to configure it the way you want. ... > a script to run 'last' repeatedly on zcatted versions of the rotated files, ... an attacker has full reign to edit the log files with impunity. ...
    (comp.os.linux.misc)
  • REQ: Raw log file generator script
    ... I mean that I want to create log files that will contain ALL POSSIBLE ... spend, entry and exit page, browser type and version, operating system, ... Unless somebody can send me a better script to create log files. ... that does not give me the raw log data. ...
    (alt.php)