Re: Logging

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: McKirahan (News_at_McKirahan.com)
Date: 01/24/05


Date: Mon, 24 Jan 2005 10:18:59 -0600


"Jeffrey" <BigDaddy@newsgroup.nospam> wrote in message
news:uW2W$qiAFHA.2880@TK2MSFTNGP14.phx.gbl...
> Does anybody know of a object or function already written to enable
logging
> in scripts. There are several of us developing scripts and trying to get
to
> a consistent logging method for the group. I'd like to get the group to
call
> either a function or use an object and pass there information.
>
>

Will this help? Watch for word-wrap.

This appends a timestamped entry to a log file.

The format of the timestamp is "ccyy-mm-dd hh:nn:ss ".

Option Explicit
Const cVBS = "logger.vbs"
Call Logger("Hello World")

Function Logger(strLOG)
'****
'* Append to Log.
'****
    Const cLOG = "logger.log"
   '*
    Dim arrNOW(5)
        arrNOW(0) = DatePart("yyyy",Now()) & "-"
        arrNOW(1) = Right(100+DatePart("m",Now()),2) & "-"
        arrNOW(2) = Right(100+DatePart("d",Now()),2) & " "
        arrNOW(3) = Right(100+DatePart("h",Now()),2) & ":"
        arrNOW(4) = Right(100+DatePart("n",Now()),2) & ":"
        arrNOW(5) = Right(100+DatePart("s",Now()),2) & " "
    Dim strNOW
        strNOW = Join(arrNOW,"")
   '*
    Dim objFSO
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Dim objOTF
    Set objOTF = objFSO.OpenTextFile(cLOG,8,true)
        objOTF.Write(strNOW & strLOG)
    Set objFSO = Nothing
    Set objOTF = Nothing
End Function



Relevant Pages

  • Re: Logging
    ... There are several of us developing scripts and trying to get ... >> a consistent logging method for the group. ... Dim strNOW ... Set objOTF = objFSO.OpenTextFile ...
    (microsoft.public.scripting.vbscript)
  • Re: Bringing it all together
    ... Right now I am attempting to use the scripts within an Access database ... Dim arrWMI ... For Each forWMI In colWMI ...
    (microsoft.public.windows.server.scripting)
  • Convert NT4 scripts to AD
    ... We have used a series of user password changing scripts that we used in our ... Dim strDomain ... Set oNTContMgmnt = Server.CreateObject ... 'There are additinal SMS account to deal with. ...
    (microsoft.public.scripting.vbscript)
  • Re: Effecient way to check, add, delete duplicates
    ... Though my below scripts works correctly, ... > Dim sh As Excel.Worksheet ... > Dim strFNameCol As String, ... strLNameCol As String ...
    (microsoft.public.excel.programming)
  • Re: Logon script - function array and select case not working
    ... I am trying to rewrite my logon scripts which are all in vbscript. ... dim dataarray() ... set objTSout = objFSO.CreateTextFile ... objTSout.writeline retrv ...
    (microsoft.public.scripting.vbscript)