'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' The function used to check whether the given file exists. '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function CheckFileExists(strFilePath)
set oFSO = createObject("Scripting.FileSystemObject")
boolFileExists = oFSO.fileExists(strFilePath)
set oFSO = Nothing
CheckFileExists = boolFileExists
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' The function used to print log '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function PrintLog(strLog, logFileName)
if not CheckFileExists(logFileName) then
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CreateTextFile logFileName, true
Set fso = nothing
end if
Set fso = CreateObject("Scripting.FileSystemObject")
Const ForAppending = 8
Set objLogFile = fso.OpenTextFile(logFileName, ForAppending, True)
strMsg = Date() & " " & Time() & " " & strLog
objLogFile.WriteLine strMsg
objLogFile.Close()
Set fso = nothing
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' The RunCommandlineTool function execute the specified command-line exe, '
' and redirect the command-line print messages to the given log file, '
' then analyze the log file to determine whether there are some errors. '
' '
' PARAMETERS: '
' @strCommand: Specify the command string, '
' @strRedirectLogFilenamePath: Specify the log file, '
' RETURN: '
' True : process succeed without any error, '
' False: process complete with some errors '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function RunCommandlineTool(strCommand, logFileName)
PrintLog """" & strCommand & """" & " Start!", logFileName
Set WsShell = CreateObject("Wscript.Shell")
Dim strShellCommand
Dim processNoError
strShellCommand = "%comspec% /c " & Chr(34) & strCommand & " >> " & logFileName & Chr(34)
WsShell.Run strShellCommand, 0, True
End Function
Dim scriptFileName
Dim logFileName
scriptFileName = WScript.Arguments(0)
logFileName = WScript.Arguments(1)
Set fso1 = createobject("scripting.filesystemobject")
Set textStream = fso1.OpenTextFile(scriptFileName, 1)
Do While Not textStream.AtEndOfStream
cmdLine = trim(textStream.readline)
i=i + 1
RunCommandlineTool cmdLine, logFileName
Loop
Set textStream = Nothing
Set fso1 = Nothing