Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function OutputToLog (strToAdd)
- Dim strDirectory,strFile,strText, objFile,objFolder,objTextFile,objFSO
- strDirectory = "c:log"
- strFile = "log-"& StampNow & ".bat"
- 'strText = "test"
- strText = strToAdd
- ' Create the File System Object
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- ' Check that the strDirectory folder exists
- If objFSO.FolderExists(strDirectory) Then
- Set objFolder = objFSO.GetFolder(strDirectory)
- Else
- Set objFolder = objFSO.CreateFolder(strDirectory)
- 'WScript.Echo "Just created " & strDirectory
- End If
- If objFSO.FileExists(strDirectory & strFile) Then
- Set objFolder = objFSO.GetFolder(strDirectory)
- Else
- Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
- 'Wscript.Echo "Just created " & strDirectory & strFile
- End If
- set objFile = nothing
- set objFolder = nothing
- ' OpenTextFile Method needs a Const value
- ' ForAppending = 8 ForReading = 1, ForWriting = 2
- Const ForAppending = 8
- Set objTextFile = objFSO.OpenTextFile _
- (strDirectory & strFile, ForAppending, True)
- ' Writes strText every time you run this VBScript
- objTextFile.WriteLine(strText)
- objTextFile.Close
- End Function
- Dim loggerFSO
- Function PrepLog
- dim objFolder
- ' Create the File System Object
- if loggerFSO is nothing then Set loggerFSO = CreateObject("Scripting.FileSystemObject")
- ' Check that the strDirectory folder exists
- If loggerFSO.FolderExists(strDirectory) Then
- Set objFolder = loggerFSO.GetFolder(strDirectory)
- Else
- Set objFolder = loggerFSO.CreateFolder(strDirectory)
- 'WScript.Echo "Just created " & strDirectory
- End If
- If loggerFSO.FileExists(strDirectory & strFile) Then
- ' do nothing
- Else
- loggerFSO.CreateTextFile(strDirectory & strFile)
- 'Wscript.Echo "Just created " & strDirectory & strFile
- End If
- End function
- Function OutputToLog (strToAdd)
- Dim strDirectory,strFile,strText, objTextFile
- strDirectory = "c:log"
- strFile = "log-"& StampNow & ".bat"
- 'strText = "test"
- strText = strToAdd
- ' Create the File System Object
- if loggerFSO is nothing then Set loggerFSO = CreateObject("Scripting.FileSystemObject")
- ' OpenTextFile Method needs a Const value
- ' ForAppending = 8 ForReading = 1, ForWriting = 2
- Const ForAppending = 8
- Set objTextFile = loggerFSO.OpenTextFile _
- (strDirectory & strFile, ForAppending, True)
- ' Writes strText every time you run this VBScript
- objTextFile.WriteLine(strText)
- objTextFile.Close
- End Function
- Dim OutputToLogFileObject
- Function OutputToLog (strToAdd)
- Dim strDirectory,strFile,strText, objFile,objFolder,objTextFile,objFSO
- If IsEmpty(OutputToLogFileObject) Then
- strDirectory = "c:log"
- strFile = "log-"& StampNow & ".bat"
- 'strText = "test"
- strText = strToAdd
- ' Create the File System Object
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- ' Check that the strDirectory folder exists
- If objFSO.FolderExists(strDirectory) Then
- Set objFolder = objFSO.GetFolder(strDirectory)
- Else
- Set objFolder = objFSO.CreateFolder(strDirectory)
- 'WScript.Echo "Just created " & strDirectory
- End If
- If objFSO.FileExists(strDirectory & strFile) Then
- Set objFolder = objFSO.GetFolder(strDirectory)
- Else
- Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
- 'Wscript.Echo "Just created " & strDirectory & strFile
- End If
- set objFile = nothing
- set objFolder = nothing
- ' OpenTextFile Method needs a Const value
- ' ForAppending = 8 ForReading = 1, ForWriting = 2
- Const ForAppending = 8
- Set OutputToLogFileObject = objFSO.OpenTextFile _
- (strDirectory & strFile, ForAppending, True)
- End If
- OutputToLogFileObject.WriteLine strText
- End Function
Add Comment
Please, Sign In to add comment