Last active
March 10, 2019 12:18
-
-
Save ezhov-da/072e3dd017988d7b81d958b1adb3cd6b to your computer and use it in GitHub Desktop.
vbs логирование в файл.vbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'БЛОК ЛОГИРОВАНИЯ VBS--------------------------------------------------- | |
Dim WshShell : set WshShell = WScript.CreateObject("WScript.Shell") | |
Dim objFS : set objFS = CreateObject("Scripting.FileSystemObject") | |
Dim file : file = fileLog | |
Dim objFile | |
Dim tfile | |
if objFS.FileExists(file) then | |
Set tfile = objFS.GetFile(file) | |
'8 - открываем для добавления | |
'1 - для чтения | |
'2 - для записи. | |
'-- | |
'-2 используем системную кодировку | |
Set objFile = tfile.OpenAsTextStream(8, -2) | |
else | |
Set objFile = objFS.CreateTextFile(file, False) | |
end if | |
WScript.Echo "[путь к файлу лога]: " & objFS.GetAbsolutePathName(file) | |
' ---------------------------------------------------------------------- | |
'ЗАВЕРШЕНИЕ БЛОКА ЛОГИРОВАНИЯ------------------------------------------- | |
objFile.Close | |
Set objFile = Nothing | |
Set objFS = Nothing | |
' ---------------------------------------------------------------------- | |
sub log(textLog) | |
Dim strLog : strLog = now() & " " & textLog | |
Wscript.echo strLog | |
objFile.WriteLine strLog | |
end sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment