4
A
回答
8
像这样:
Set shell = CreateObject("WScript.Shell")
shell.LogEvent 4, "Your Message Here"
4是严重性级别。您可以通过MSDN了解有关LogEvent
方法的更多信息。
1
这是旧的,但我肯定仍然有效。
http://msdn.microsoft.com/en-us/library/b4ce6by3
你还需要的权限能够写入到事件日志,以便根据用户运行脚本,你可能还是我用不上。
+0
谢谢你的帮助。在哪里写日志?我找不到它 – Emree
1
您可能只想写入您自己的日志文件。
检查出我的链接更多的信息和细节
http://www.yeshaib.com/2010/08/vbscript-in-the-logging/
'----------------------------------------------------------------------
'
' Please Enter Updates with date and name including line of Change
'----------------------------------------------------------------------
'----------------------------------------------------------------------
set objShell = CreateObject("Wscript.Shell")
set objFSO = CreateObject("Scripting.FileSystemObject")
'--- Main Begins ---------------------------------------
WriteToLog("Generic Log.vbs - Write This")
'--- Main Ends -----------------------------------------
'--- Write to log --------------------------------------
Sub WriteToLog(strLogMessage)
Const ForAppending = 8
Const vbsName = "Generic Log"
strLogFileName = "C:\GenericLog.log"
strLogEntryTime = NOW
'test whether file exists To either write/append to file
if objFSO.FileExists(strLogFileName) Then
Set objLogFileTransaction = objFSO.OpenTextFile(strLogFileName, ForAppending)
Else
Set objLogFileTransaction = objFSO.CreateTextFile(strLogFileName)
End if
objLogFileTransaction.WriteLine strLogEntryTime & chr(9) & chr(58) & chr(9) & vbsName & chr(9) & chr(58) & chr(9) & strLogMessage
objLogFileTransaction.Close
WScript.StdOut.WriteLine strLogMessage
WScript.StdOut.WriteLine ""
End Sub
相关问题
- 1. 写入Windows事件日志使用PowerShell
- 2. 如何使用C#在Windows Server 2008中写入事件日志?
- 3. 使用sp_addmessage写入事件日志与不同的事件ID
- 4. 我如何写事件源的Windows日志事件
- 5. 将事件日志写入文件,powershell
- 6. 写事件日志不写入应用程序日志(注册优先源后)
- 7. 如何使用SLF4J或Logback将事件日志写入xml文件?
- 8. 写入/读取到Windows事件日志
- 9. 写入事件日志时发生System.Security.SecurityException
- 10. NLog:无法写入事件日志
- 11. NLog不写入事件日志
- 12. 写入Delphi中的事件日志
- 13. 无法写入到事件日志
- 14. 无法事件日志写入指定的日志
- 15. 在windows事件日志中写入activemq日志
- 16. 事件日志(事件日志创建事件)
- 17. 如何使Apache通用日志记录写入特定光盘日志文件
- 18. 使用My.Application.Log.WriteException写入事件日志的安全问题
- 19. 在使用模拟时编写事件日志
- 20. 使用Visual Studio C++编写Windows事件日志6
- 21. 如何使用Python的日志模块将日志文件中的上一行写入日志文件?
- 22. 如何使用不存在的源代码写Windows事件日志记录
- 23. 如何使用nlog写入具有临界级别的事件日志?
- 24. 如何写入自定义Windows事件日志?
- 25. 如何将日志写入安全事件登录C#?
- 26. 如何在asp.net core 1.1中编写microsoft事件日志?
- 27. 如何从Java写入Windows事件日志?
- 28. 如何在写入事件日志时避免此SecurityException?
- 29. 用VBscript写入应用程序和服务日志
- 30. 在C#中写入事件日志 - 写入应用程序日志时是否需要使用EventLog.CreateEventSource?
谢谢你的帮助。在哪里写日志?我没有找到它 – Emree
@Emree - 它应该将它写入事件查看器。你可以通过运行运行对话框中的'compmgmt.msc'来找到。查看Google的事件查看器。 – vcsjones