With some of our recent software deployments, we’ve used VBscript to install the software package(s). We have a dedicated team which develops these installation scripts. And their VBscripts mostly works well, except when they don’t.
Like when a user gets in the way of the install.
And when the user gets in the way of the install, we often don’t know what’s happened as we don’t include logging in these VBscripts.
Until now that is. I got tired of treating to guess where a script has failed, so I developed a 10 line function to drop into existing VBscripts, which will provide some logging.
Here it is:
dateStamp = Now()
Set objFsoLog = CreateObject("Scripting.FileSystemObject")
Set logOutput = objFsoLog.OpenTextFile(sLogFileName, 8, True)
logOutput.WriteLine(cstr(dateStamp) + " -" + vbTab + sLogFileLine)
Set logOutput = Nothing
Set objFsoLog = Nothing
You call it with the following syntax:
Call WriteLogFileLine(“LogFileName”,"Log Message")
It writes a log file which looks like this:
16/07/12 1:42:20 PM - Starting Install_KBv6
16/07/12 1:42:21 PM - Hotfix not found - calling InstallKB
16/07/12 1:42:21 PM - Applying newest hotfix.
16/07/12 1:42:21 PM - Function InstallKB
16/07/12 1:42:28 PM - Calling objWsh.Run with following command: "\\NODDY\IE8-WindowsXP-KB2699988-x86-ENU.exe" /Quiet /NoRestart
16/07/12 1:43:58 PM - intResult 3010 Returned.
It has made investigation of software install failures much easier.