Skip navigation

So how’s it going?

Alright, so current progress.  I am into week 5 of my regimen.  Current overall gains and losses are roughly 10% body fat (roughly 33mm of fat density), and +6 lbs of lean body mass with an overall weight loss of 10 lbs.

I actually had greater gains in my LBM, but lost a pound due to less then ideal caloric intake the last week of January.  I’ve since adjusted my caloric intake now and feel the difference in the gym and see it in the mirror.

 


So what am I eating?


Well, first my rule of thumb. 

Clean calories (few indulgences)

Avoid sugars, natural or refined (occasional exceptions for glycogen levels post workout)

Little to No dairy

No additional fats

      • 2 Egg White and Oatmeal Pancakes with Sugar Free syrup and 1 cup of cheerios dry with 12oz black coffee.
  • 5oz Eye of round (steak) with green beans and onions and 1/2c dry oats (with a dash of Truvia)
  • 4oz Turkey tenderloin on toasted wheat with mustard and pickles
  • 5oz Pulled chicken breast with Texas Pete Buffalo sauce and pickles 12oz black coffee
  • 1/2c oats with 1 scoop protein powder 8oz water
  • 1 scoop protein powder 8oz water & 6oz with C4 workout days / 5oz Pulled chicken breast and brown rice mixed on off days
  • 5oz Eye of round (steak) with green beans and onions
  • 1 – 2 gallons of water during the course of the day

I’ve also swapped my breakfast a few times for an Acai Berry + Blue Berry + Banana + Protein Powder smoothie a few mornings when sugars were needed.

I will shuffle my meals around on occasion for variety, but largely stick to heavy digesting protein in the morning and night with lighter ones during the day and strong morning carb intake with 0 after my workout in the evenings.  Currently my macros break down to:

Protein / Carbs / Fat

51 / 41 / 8

I don’t think these macro levels are sustainable, but I am attempting to cut while still developing clean muscle.  So essentially I’m walking a fine line of keeping my carbs at a level they keep glycogen levels up and aid in muscle repair with plenty of protein for the repair and limiting fats in an attempt to promote stored fat usage in these processes.

I can generally tell when I’m firing off fat for energy because it’s a really short burst of power then just an overall dip in my lifts.  Nights where I’ve felt it worse then others I’ve put some cheerios in my belly with my last meal.

 


What about the gym?


 

Well this is where it gets interesting.  As I stated before, I am following Kris Gethin’s 12-week hardcore plan.  Now I’m going to stop here for one second and kind of plug both bodybuilding.com and Kris Gethin.  If you are interested in fitness, don’t know where to start, or are a fitness junkie and just want more and more information then Bodybuilding.com is one of the best resources I could recommend.  As for Kris Gethin, there is something to be said for a personal trainer who takes the time to throw together such in depth material and post it for free.  Does he profit from this stuff, sure, he’s a BB employee; but he has a passion for what he does, and WANTS to help others reach their goals.

With all that being said, I largely stick to his prescribed workouts for the day with little to no variation.  If I’ve made variations it’s been to either:

  1. Increase intensity
  2. Equipment not available
  3. Focus on lagging areas
  4. Recovery dates have been shuffled as well

 

Generally speaking though it’s a 5 day split which simply means 2 on 1 off 3 on 1 off (or some variant).  Kris shuffles that schedule a lot for multiple reasons and shuffles targeted muscle groups quite a bit as well.

Low intensity cardio in the morning, and evening even on off days (for me around 124 – 135 bpm) @ 20 – 30 minutes.  Something I’m also doing that Kris has in his program I like is ending with 150 abdominal twists.

I think anyone starting out should really give this a go.  I highly recommend following a structured plan like Kris’s initially to really glean useful information and discipline.  With this plan he offers a video a day to give you little tid bits of information that will really help to educate you as much as motivate you.  Also for women, there are plenty of free plans to follow as well such as Jamie Eason’s Live Fit.

I wish I had known about BB back when I really started.  After spending the past 4 years dealing with my fitness and health I finally feel like I’ve learned to listen to what my body is telling me and respond in kind.

 

Sum it up?

  • Keep excess calories and fat in check.
  • Increase thermogenesis through constant eating and cardio
  • Vary routines and resistance volume to force muscles to adapt and grow

 

Have a good one.

I’ve got a fairly large amount of content I’d like to post and discuss:

  • Current workout/diet regiment, and results so far
  • SCCM health check script and logon framework I’ve been working on
  • Theological view on harmony, and mans self importance

However, between my work schedule, and workout schedule I’ve had little free time and now I’m fighting a sinus infection. Instead of just blowing off my blog completely I wanted to of course post this, as perhaps more an outline for subjects I wish to cover this coming month.

Until then, take care.

A simple vbscript I use for manual client installation. It does some basic quick checks and fixes before begining an install. One could feasibly use this for health checking, but it’s not nearly as robust as my actual logon framework or other scripts from people like Jason Sandys or Dan Thompson.

The variables strAdmin (local admin service account), strCcmSetup (path to folder with the ccmsetup.exe), and strArguement (install string) need to be defined before running the script. It’s worth mentioning that strCcmSetup is just the path to ccmsetup.exe, there is no need to actually type ccmsetup.exe into the path and it’s best if you don’t since I didn’t bother writing anything in to verify if it is or isn’t. The script will auto append the executable to that variable so ccmsetup.exe in the path will give you ccmsetup.execcmsetup.exe

'Author Daniel Belcher             ||
'CCMsetup Function                 ||
'Date 2/11/2011 rev 5/20/2011      ||
'==================================||
'|Objects, Variables, and Constants ********************************************
'=============================================================================||
'|| Non-Standard Installer Variables - Please define them                     ||
'|| Admin Account
	strAdmin = "domain\user"
'|| Path to ccmsetup.exe
	strCcmSetup = "\\path\where\ccmsetup.exe\resides\"
'|| Install string
	strArguement = "/noservice SMSSITECODE=ABC SMSSLP=SERVER.ADDRESS " _
				& "SMSFSP=SERVER.ADDRESS"
'                                                                             ||
'=============================================================================||
Const DEBUGMSG = False 'Boolean to use for testing False = Silent True = Verbose
Const ForAppending = 8
Dim oWShell
Set oWShell = CreateObject("WScript.Shell")
Dim oFSo
Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim oNet
Set oNet = CreateObject("Wscript.Network")
ComputerName = oNet.ComputerName
Dim Target
Target = "."
Dim oWMISvc
Set oWMISvc = GetObject("winmgmts:\\"&Target)
'|Main Run *******************************************************************||
'=============================================================================||
WriteLog "Starting "&Wscript.Scriptname&" on "&ComputerName,2
PreReq
CCMSetup
Report
'SubRoutines *****************************************************************||
'=============================================================================||
Sub WriteLog(msg,mtype)
'Subroutine for writing the log
logname = wscript.scriptname&".log"
if not oFSo.FileExists(logname) then
oFSo.CreateTextFile(logname)
end if

msgline = "<![LOG["&msg&"]LOG]!><time="&""""&DatePart("h",Time)
msgline = msgline &":"&DatePart("n",Time)&":"&DatePart("s",Time)
msgline = msgline &".000+0"""&" date="""&Replace(Date,"/","-")
msgline = msgline &""""&" component="""&WScript.ScriptName
msgline = msgline &""" context="""" type="""&mtype
msgline = msgline &""" thread="""" file="""&WScript.ScriptName& """>"

Set oLogFile = oFSo.OpenTextFile(logname, ForAppending, True)
    oLogFile.WriteLine msgline
oLogFile.Close
if DEBUGMSG then wscript.echo msg&" "& mtype
End Sub
'*******************************************************************************
Sub SvcStart(service)
'Attempts to start a service
Set WMIServices = oWMISvc.ExecQuery _
("Select * from Win32_Service where name = '"&service&"'")
     For Each item in WMIServices
         if lcase(item.startmode) <> "automatic" then
                             item.ChangeStartMode("Automatic")
         end if
         start = item.startservice()
         wscript.sleep 4000
           if start <> 0 Then
                   WriteLog "ERROR: Failed to start the "&service&" Service, " _
                   & "investigation required", 3
                             wscript.quit(0)
                    else
                    WriteLog "Succesfully started "& service &" Service",1
           end if
     next
End Sub
'|Functions ******************************************************************||
'=============================================================================||
Function PreReq
'Prerequisite check for client installation
Set WMIServices = oWMISvc.ExecQuery _
("Select * from Win32_Service")
strService = "lanmanworkstation"
regAdminSPath = "HKLM\SYSTEM\CurrentControlSet\services\LanmanServer\" _
				& "Parameters\"
 For Each item in WMIServices
          if lcase(item.name) = strService then
             if lcase(item.state) <> "running" then
                writelog "Warning: "&strService&" was not running, " _
                & "attempting to start...", 2
                SvcStart strService
             else
                 writelog strService& " was found running, OK", 1
             end if
          end if
 next
if not oFSO.FolderExists("\\"&computername&"\admin$") then
WriteLog "Warning: Admin shares not available, attempting to add " _
		& "registry key...", 2
    On Error Resume Next
oWShell.RegWrite regAdminSPath & "AutoShareWKS", 1, "REG_SZ"
              if err.Number <> 0 then
WriteLog "ERROR: "&regAdminSPath&"AutoShareWKS, 1 failed to write, or " _
		&"already exists.", 3
                  else
WriteLog regAdminSPath&"Notice: AutoShareWKS, 1 written succesfully. " _
					& " Restart required to take effect.", 2
              end if
Wscript.Echo "AutoShareWKS key was written to: " &vbcrlf _
          &regAdminSPath & vbcrlf _
          &"Please restart the machine, and rerun this script"
else
WriteLog "Admin$ shares found, and working.", 1
end if
Set AdminCheck = GetObject("WinNT://" & oNet.ComputerName _
							& "/Administrators,group")
if AdminCheck.IsMember("WinNT://"& strAdmin) then
WriteLog "User "&strAdmin&" found in Local Adminstrators group", 1
        else
WriteLog "Warning: User "&strAdmin&" not found in Local Administrators group",2
        on Error Resume Next
           AdminCheck.Add("WinNT://"&strAdmin)
        if Err.Number <> 0 then
WriteLog "ERROR: Unable to add "&strAdmin&" to the Local Administrators group",3
           Wscript.Echo "Unable to add "&strAdmin&" to local Admins." & vbcrlf _
           &"Please do so manually and rerun this script."
           Wscript.Quit(0)
        end if
end if

End Function
'*******************************************************************************
Function CCMSetup
'Client detection and installation
Set WMIServices = oWMIsvc.ExecQuery _
("Select * from Win32_Service where name ='ccmexec'")
boorun = true
   for each objservice in WMIServices
       strservice = lcase(objservice.name)
           if strservice = "ccmexec" then boorun = "False"
   next
if not boorun then
For Each service in WMIServices
  if lcase(service.state) <> "running" then
     svcStart "ccmexec" 'Attempt to start service if stopped
WriteLog "Warning: CcmExec service found, but was not running, " _
		& "attempting to start...", 2
  end if
next
WriteLog "SCCM client service, CcmExec found, closing script", 1
	exit function
end if
if boorun then
oWShell.run strCcmsetup&"ccmsetup.exe " & strArguement
        WriteLog "CcmSetup has begun using: ccmsetup.exe"& strArguement,1
end if

End Function
'******************************************************************************
Function Report
 If DEBUGMSG then msgbox "Complete" 'Set for popup on script complete
End Function
'End *************************************************************************||
'=============================================================================||

As has become my standard, the logs are written in a markup that works with trace32.

I just wanted to make a brief post to let all my readers and loved ones who read my blog know that I am ok.

My wife was a bit shook up as she hates tornadoes, and we count ourselves lucky that this one missed us as well. We’ve already begun to hear reports of fatalities in the town/suburb just north west of us.

Prayers for those affected.

So today marks the 6th day of my new workout regiment.  A rest day, or as I like to call it “not make myself any more sore for tomorrow” day.

For anyone interested, I’m following Kris Gethin from bodybuilding.com 12 week hardcore schedule.  7 meals, light cardio every morning and evening, lift two then rest one.

I will do a better job of progress recording this time through and hopefully get something posted at the end or near the end for people to judge me….

Well, enough blogging.  Time to go help clean the house.

So similarly to the logging class object I posted back on December 16th; I’m posting a dictionary wrapper object I’ve built to enhance it’s (scripting.dictionary) usage for creating indexed arrays, concatenating strings, etc…

As with the Logging class object, it must be instantiated to use, so…

Dim Dict
Set Dict = New cls_Dict
 
Call Dict.Add("stuff","my message")
	Wscript.Echo Dict.Key("stuff") 

Wscript.Quit(0)

The object code is below, I’ll give a walkthrough on it’s usage after the code.

'============================================================================
'Dictionary Class ===========================================================
'============================================================================

Class cls_Dict
'Class wrapper for the scripting.dictionary
	Private oDict, oNet, Comparemode, strSplit, oFso, oWShell

'---------------------------------------------------------

Private Sub Class_Initialize()
'Dictionary class init subroutine    
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
		Set oDict 	= CreateObject("Scripting.Dictionary")
		Set oNet	= CreateObject("Wscript.Network")
		Set oFso	= CreateObject("Scripting.FileSystemObject")
		Set oWShell = CreateObject("Wscript.Shell")
		oDict.CompareMode = 1
			strSplit = "|:|"
		Call oDict.Add("CurrentDir",Left(WScript.ScriptFullName, _
			(Len(WScript.ScriptFullName)-Len(WScript.ScriptName))))
		Call oDict.Add("computername", oNet.Computername)
		Call oDict.Add("Windir",LCase(oWShell.ExpandEnvironmentStrings _
			("%windir%")))
		Call oDict.Add("CurrentUser",LCase(oNet.UserName))
		Call SetOsVer
End Sub

'---------------------------------------------------------

Private Sub Class_Terminate()
'Dictionary class termination subroutine
	If IsObject(oDict) then Set oDict = Nothing
End Sub

'---------------------------------------------------------

Public Property Get CurrentDir
'Returns Current Directory for the script
	CurrentDir = oDict.Item("CurrentDir")
End Property

'---------------------------------------------------------

Public Property Get ComputerName
'Returns the machine name for the current machine
	ComputerName = oDict.Item("computername")
End Property

'---------------------------------------------------------

Public Property Get CurrentUser
'Returns the machine name for the current machine
	CurrentUser = oDict.Item("CurrentUser")
End Property

'---------------------------------------------------------

Public Property Get Windir
'Returns the windows directory for the local machine
	Windir = oDict.Item("windir")
End Property

Public Property Get SystemRoot
'Returns the appropriate system directory system32 or syswow64

	If InStr(StrReverse(oDict.Item("CurrentOsVer")), "46x") <> 0 Then 
		SystemRoot = Windir & "\syswow64"
	Else
		SystemRoot = Windir & "\system32"
	End If

End Property
'---------------------------------------------------------

Public Sub Add(strKey,strValue)
'Method to Add a key and item
	If Debugmode Then On Error Goto 0 Else On Error Resume Next

    Dim EnvVariable, strSplit

    	strSplit = Split(strValue, "%")
	If IsArray(strSplit) Then 
    	EnvVariable = oWShell.ExpandEnvironmentStrings _
    		("%" & strSplit(1) & "%")
    	strValue = strSplit(0) & EnvVariable & strSplit(2)
    			If strValue = "" Then
    				strValue = strSplit(0)
    			End If
    End If
	If oDict.Exists(strKey) Then
		oDict(strKey) = Trim(strValue)
	Else
		oDict.Add strKey, Trim(strValue)
	End If
End Sub

'---------------------------------------------------------

Public Function Exists( strkey)
'Method to check existance of a key
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
	
	If oDict.Exists(strKey) then 
		Exists = True
	Else
		Exists = False
	End If

End Function

'---------------------------------------------------------

Public Function Keys()
'Method to retrieve an array of keys
    If Debugmode Then On Error Goto 0 Else On Error Resume Next

	If IsObject(oDict) Then
		Keys = oDict.Keys
	End If
End Function

'---------------------------------------------------------

Public Function Items()
'Method to retrieve an array of items
    If Debugmode Then On Error Goto 0 Else On Error Resume Next

	If IsObject(oDict) Then
		Items = oDict.Items
	End If
End Function

'---------------------------------------------------------
Private Sub SetOsVer()
'Sets a comparable OSVer key item into the dictionary
		If DebugMode Then On Error Goto 0 Else On Error Resume Next

		Dim x, VersionCheck	
		
	VersionCheck = owShell.RegRead("HKLM\software\microsoft\" _
					& "windows nt\currentversion\productname")

			If ofso.folderexists("c:\windows\syswow64") Then
				x = "x64"
			Else
				x = "x86"
			End If
		Call oDict.Add("CurrentOsVer",VersionCheck & " " & x)
End Sub
	Public Property Get OsVer()
		OsVer = oDict.Item("CurrentOsVer")
	End Property

'---------------------------------------------------------
Public Property Get AppName()

	AppName = Left(WScript.ScriptName, Len(WScript.ScriptName) - 4)
End Property 

'---------------------------------------------------------

Public Property Get Key( strKey)
'Property to retrieve item value from specific key
    If Debugmode Then On Error Goto 0 Else On Error Resume Next

		Key = Empty
	If IsObject(oDict) Then
		If oDict.Exists(strKey) Then Key = oDict.Item(strKey)
	End If
End Property

'---------------------------------------------------------

Public Sub ItemJoin(strKey, strItem)
'Method to concactenate new items under one key at the end of the string
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
	Dim concat
	If Not oDict.Exists(strKey) Then
		Call oDict.Add(strkey, stritem)
	Else
		concat = oDict.Item(strKey)
		concat = concat & " " & strItem
			oDict.Remove(strKey)
		Call oDict.Add(strKey,concat)
	End If
End Sub

'---------------------------------------------------------

Public Sub ItemList( strKey,  strItem)
'Method to concactenate new items under one key at the end of the string
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
	Dim concat
	If Not oDict.Exists(strKey) Then
		Call oDict.Add(strkey, stritem)
	Else
		concat = oDict.Item(strKey)
		concat = concat & "|:|" & strItem
			oDict.Remove(strKey)
		Call oDict.Add(strKey,concat)
	End If
End Sub

'---------------------------------------------------------

Public Sub ItemJoinRev( strKey,  strItem)
'Method to concactenate new items under one key at the start of the string
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
	Dim concat
	If Not oDict.Exists(strKey) Then
		Call oDict.Add(strkey, stritem)
		Exit Sub
	Else
		concat = oDict.Item(strKey)
		concat = strItem & " " & concat
			oDict.Remove(strKey)
		Call oDict.Add(strKey,concat)
	End If
End Sub
	
'---------------------------------------------------------	

Public Function ReturnArray( strKey)
'Method to return an item as an array
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
	
	Dim ItemToSplit, ItemArray
	
	ItemToSplit = oDict.item(strKey)
	
	ItemArray = Split(ItemToSplit, strSplit)
	
	ReturnArray = ItemArray	
	
End Function
	
'---------------------------------------------------------	

Public Sub Remove( strKey)
'Method to remove a key value
	oDict.Remove(strKey)
End Sub

'---------------------------------------------------------

Public Sub RemoveAll()
'Method to remove all data from the dictionary
	oDict.RemoveAll
End Sub

End Class

 

So let’s look at the exposed functionality added to or exposed from the scripting dictionary by this object. 

Methods:

 

  • Add

Modified to resolve and accept environment variables, and is also the sole method for adding and replacing keys and their item values

  • ItemJoin

Concatenates the item value to the end of the existing key item

  • ItemJoinRev

Concatenates the item value to the beginning of the existing key item

  • ItemList

Creates an array under an existing key or creates if it doesn’t exist

  • ReturnArray

Returns an array if array exists under the key

  • Exists

Checks if key exists, returns boolean value

  • Items

Returns all items in an array

  • Keys

Returns all keys in an array

  • Remove

Remove a key and item value

  • RemoveAll

Dump entire contents of the dictionary object

 

Properties:

 

  • Key

This is modified from the original usage, and returns the item for the given key. Add is used to modify the key only.

  • AppName

Returns script name, minus extension value

  • ComputerName

Returns the netbios name of the machine

  • CurrentDir

Returns the current working directory of the script

  • CurrentUser

Returns the current logged on user ID (or executing id)

  • OsVer

Returns a OS Version and arch

  • SystemRoot

Returns the environment path for the system root

  • Windir

Returns the environment path for the Windows directory


Feel free to hit me up about usage or any other questions you might have regarding why I did things a certain way, or with any changes you might have made to improve this code.

I had thought to have more time to blog and post things of interest now that the holidays had passed and the core portion of my logon framework was completed but something(s) unexpected happened.  We arrived home and decided to go out to eat dinner when my wife received a phone call that her closest cousin’s 7 month old son had died suddenly at the sitters.  This passing was followed by the news of 3 others close to me; 1 co worker and 2 old family friends.

There is hope in their passing that I will see them all again.  With that I find peace, but continue to pray for their loved ones and those who feel the immediate loss in their life.  One of my favorite analogies of death is that, it’s like losing an arm.  Things will never be the same, but eventually you learn to live without it. 

To those learning how to live again, my heart goes out to you, sincerely.

Due to awkward travel plans around this time of year, tomorrow is my Christmas morning with my wife and kids.  The excitement I feel as a parent towards seeing my kids faces (and wife) as they see/open their presents is quite an exciting feeling.  I hope/pray everyone else is able to find joy at this time and that you not forget why we celebrate this time.

Unrelated to the holidays, but I’ve finalized the first build of the logon framework/script I’ve been working on.  With it I intend to post the dictionary wrapper object I built along with (eventually) the full code base with xml config (scrubbed of course).

Happy holiday, and peace be with you.

Ok, so I’ve not posted anything for a few days and I felt the need to throw a brief technical post up with a code snippet from a current project I’m working on. I’m building a health check logon script and as part of that framework I wanted to build a logging object. Since the target format has to be vbscript for what I’m doing, I’ve built it as such, and in a format that views nicely inside of trace32 and trace64.

The idea was to build an object that would perform a simple task, write a log file…. then write a log file, or an event, then write only error events, but could also buffer and dump a final error or success log as a split log to another remote location. All configurable via properties, but with only two exposed methods to control it all (write & writeremote). This object is instantiated by:

Dim Logging
Set Logging = New cls_Logging

Call Logging.Write("my message",1)

Wscript.Quit(0)

Simple enough, no? It’s also worth mentioning I wrote the code so that a constant could be set within the instantiating script of DEBUGMODE and if TRUE it will error, else suppresses all error output.

Here’s the code:

'=================================================================================
'Logging Class ===================================================================
'=================================================================================

'Not required for WSF, but is when in standard VBS
Const ForAppending = 8

'Log and Event writer object
Class cls_Logging
'Class for logging to file and event viewer

Private oWShell,oNet,oFSo,Filehandle,rFilehandle
Private fPath,strRFPath,fMaxSize,fLogname,strRemoteErr,BoolEvent,BoolRemote,oDict

Private Sub Class_Initialize()
    'Object Init subroutine
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
    Set oWShell 	= CreateObject("Wscript.Shell")
	Set oNet 		= CreateObject("Wscript.Network")
	Set oFSo 		= CreateObject("Scripting.FileSystemObject")
	Set oDict		= CreateObject("Scripting.Dictionary")
		LogEvent 	= False
		RemoteLog	= False
		Path 		= Left(WScript.ScriptFullName,(Len(WScript.ScriptFullName)_
						-Len(WScript.ScriptName)))
		File 		= LCase(oNet.ComputerName)
		MaxSize = 2
End Sub

'---------------------------------------------------------

Private Sub Class_Terminate()
	'Object Termination subroutine
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
	If bOpen Then
		Filehandle.close
	End If
		Set oWShell = Nothing
		Set oNet = Nothing
		Set oFSo = Nothing
		Set Filehandle = Nothing
		Set fPath = Nothing
		Set fMaxSize = Nothing
		Set fLogname = Nothing
		Set BoolEvent = Nothing
End Sub

'---------------------------------------------------------
'File name properties, for changing and retrieving the log file name
Public Property Let File(strFile)
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
	If (InStr(StrReverse(strFile),"gol.")) <> 0 Then
		fLogname = strFile
	Else
		fLogname = strFile & ".log"
	End If
End Property
		Public Property Get File()
		    If Debugmode Then On Error Goto 0 Else On Error Resume Next
				File = fLogname
		End Property

'---------------------------------------------------------
'Path name properties, for changing and retrieving the path to logs
Public Property Let Path(strPath)
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
		If (InStr(StrReverse(strpath),"\")) <> 1 Then
			fPath = strPath & "\"
		Else
			fPath = strPath
		End If
End Property
		Public Property Get Path()
		    If Debugmode Then On Error Goto 0 Else On Error Resume Next
			Path = fPath
		End Property
		
'---------------------------------------------------------
'Fully concatenated file name property for retrival.
		Public Property Get FullFileName()
			FullFileName = Path & File
		End Property

'---------------------------------------------------------
'Property for setting maximum file size of log file
Public Property Let MaxSize(strVal)
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
	fMaxSize = Cint(strVal) * 1048576
End Property
		Public Property Get MaxSize()
    		If Debugmode Then On Error Goto 0 Else On Error Resume Next
			MaxSize = fMaxSize
		End Property

'---------------------------------------------------------
'Boolean property to determine if the filehandle is in use
Private Property Get bOpen()
	If Debugmode Then On Error Goto 0 Else On Error Resume Next	
		If IsObject(Filehandle) Then
			bOpen = True
		Else
			bOpen = False
		End If
End Property

'---------------------------------------------------------
Public Property Let LogEvent( blValue)
'Bool property that dictates event viewer rights
	BoolEvent = blValue
End Property
	Private Property Get LogEvent()
		LogEvent = BoolEvent
	End Property
	
Public Property Let RemoteLog( blValue)
'Bool property that dictates if logging occurs to remote location
	BoolRemote = blValue
End Property
	Private Property Get RemoteLog()
		RemoteLog = BoolRemote
	End Property
Public Property Let RemotePath( strPath)
		If (InStr(StrReverse(strpath),"\")) <> 1 Then
			strRFPath = strPath & "\"
		Else
			strRFPath = strPath
		End If
End Property
	Public Property Get RemotePath()
		RemotePath = strRFPath
	End Property

'---------------------------------------------------------
Private Sub RemoteErrBuffer( strKey,  strItem)
'Method to concactenate new items under one key at the end of the string
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
		Dim concat

	If Not oDict.Exists(strKey) Then
		Call oDict.Add(strkey, stritem)
	Else
		concat = oDict.Item(strKey)
		concat = concat & "|:|" & strItem
			oDict.Remove(strKey)
		Call oDict.Add(strKey,concat)
	End If

End Sub

'---------------------------------------------------------
Public Function ErrBuffer()
'Method to return contents of the error buffer
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
    
    Dim ItemToSplit, ItemArray, item
	
	ItemToSplit = oDict.item("remotelog")
	
	ItemArray = Split(ItemToSplit, "|:|")
	
	ErrBuffer = ItemArray
	
End Function
'---------------------------------------------------------
Public Sub WriteRemote(strVal)
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
    	
	If Not CreateRemote Then
		Exit Sub
	End If

		rFilehandle.WriteLine strVal

End Sub

'---------------------------------------------------------
'Subroutine for creating the remote log file and instantiating the handle
Private Function CreateRemote()
    If Debugmode Then On Error Goto 0 Else On Error Resume Next

	Dim FileProperty,Logsize

	CreateRemote = False

	If Not oFso.FolderExists(RemotePath) Then 
		Call Write(RemotePath & " Does not exist, or is unreachable.",3)
			Exit Function
	End If 

	If Not oFSo.FileExists(RemotePath & File) Then
		oFso.CreateTextFile(RemotePath & File)
	Else
		oFSo.DeleteFile(RemotePath & File)
			oFso.CreateTextFile(RemotePath & File)
	End If    
		If Not IsObject(rFilehandle) Then
	       	Set rFileHandle = oFSo.OpenTextFile(RemotePath & File, _
	       	 ForAppending, True)
	    End If
	If oFSo.FolderExists(RemotePath) Then
		CreateRemote = True
	End If
End Function

'---------------------------------------------------------
'Subroutine for writing log entries
Public Function Write( msg,  mtype)
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
	Dim msgline, etype
		Call Create()

		If Not bOpen Then
			Call Create()
		End If
    msgline = "<![LOG["&msg&"]LOG]!><time="&""""&DatePart("h",Time) _
    &":"&DatePart("n",Time)&":"&DatePart("s",Time)&".000+0"""&" date=""" _
    &Replace(Date,"/","-")&""""&" component="""&Left(WScript.ScriptName, _
    Len(WScript.ScriptName)-Len(".vbs"))&""" context="""" type="""&mtype _
    &""" thread="""" file="""&Left(WScript.ScriptName,Len(WScript.ScriptName)_
    -Len(".vbs"))& """>"

	Filehandle.WriteLine msgline


		Select Case Mtype
			Case 1
				etype = 0
			Case 2
				etype = 2
						If LogEvent Then
					oWShell.LogEvent etype, msg
						End If 
					Call RemoteErrBuffer("remotelog", msg  & "," & "2")
			Case Else
				etype = 1
						If LogEvent Then
					oWShell.LogEvent etype, msg
						End If
					Call RemoteErrBuffer("remotelog", msg  & "," & "1")
		End Select
	
End Function

'---------------------------------------------------------
'Subroutine for rolling over log file at file size limit
Private Sub Rollover()
    If Debugmode Then On Error Goto 0 Else On Error Resume Next
	If bOpen Then
		Filehandle.Close
	End If
	oFso.CopyFile FullFileName, Left(FullFileName,(Len(FullFileName)-1)), True
		oFSo.DeleteFile FullFileName
	Set FileHandle = oFSo.OpenTextFile(FullFileName, ForAppending, True)			
End Sub

'---------------------------------------------------------
'Subroutine for creating the log file and instantiating the handle
Private Sub Create()
    If Debugmode Then On Error Goto 0 Else On Error Resume Next

	Dim FileProperty,Logsize

	If Not oFSo.FileExists(FullFileName) Then
		oFSo.CreateTextFile(FullFileName)
	End If    
		If Not bOpen Then
	       	Set FileHandle = oFSo.OpenTextFile(FullFileName, ForAppending, True)
	    End if
	Set FileProperty = oFSo.GetFile(FullFileName)
				Logsize = FileProperty.size
	If Logsize > MaxSize Then
			Filehandle.WriteLine "\\\\\\\\\\File Size Reached//////////"
		Call Rollover()
	End If
End Sub
End Class

I built a scripting dictionary wrapper as well which was inspired by work from Dan Thomson in his health check script. I’ll most likely post it next after I feel it’s complete.

If you found this object helpful, or otherwise, I would appreciate it if you rated it on script center.

I’ve been slap busy with work, and late night coding.  So another tag blog post with an interesting video I ran across via Google+ (hosted by YouTube).

Thoughts?