我可以从Windows脚本语言(如JScript)写入Windows事件日志吗?
Can I write into Windows Event Log from a Windows Scripting Language like JScript?
我有一个小的JScript代码,需要输出它的错误消息。它从Windows脚本主机(作为.js文件)运行。我想知道是否有可能从它写入Windows事件日志?
您可以使用WscriptShell对象本身直接记录事件:
var oWSS = new ActiveXObject("WScript.Shell");
oWSS.LogEvent(1,"this is error");
oWSS.LogEvent(2,"this is warning");
oWSS.LogEvent(4,"this is Info");
这个博客是这样做的:
function Log(message) {
var shell = new ActiveXObject("WScript.Shell")
shell.Exec('eventcreate /id 1 /l [LOG] /SO [SOURCE] /T ERROR /D "' + String(message).replace('"', '""') + '"')
}
相关文章:
- touchmove/MPointerMove事件在Windows 8中未启动
- ActiveX ListControl 事件在 Windows 更新后不再起作用
- Windows 8 HTML5 JavaScript 应用程序中向左滑动的事件名称是什么
- 捕获在Windows应用程序中启动其他应用程序的用户事件
- 如何在 Windows Mobile 5 浏览器中检测 JavaScript 密钥事件
- Windows 10 UWP HTML/Winjs应用程序从共享魅力启动时未接收到激活的事件
- 使用WinJs构建的Pivot的幻灯片事件没有'不适用于windows Phone
- Windows.Scroll事件在Android Web View上不起作用
- 如何使用 onload 事件从 HTML 网站在 Windows 2008 上的文件共享上运行批处理文件
- 如何处理 Windows 8.1 触摸屏中的鼠标悬停和鼠标离开事件
- 在带有触摸屏的 Windows 8 上检测 Chrome 中的触摸事件
- javascript windows postMessage在初始事件后返回消息
- Windows侧边栏单击事件不起作用
- 在javascript Windows 8 Metro Style应用程序中切换应用程序栏的事件是什么
- 在通用Windows应用程序(JS/HTML)的HTML中注册onclick事件
- 将事件集中在Windows 7上的IE 11
- 点击事件和Google Chrome和Windows 8
- 在Windows 8 html5的挂起状态事件处理程序中写入文本文件
- 如何订阅Windows Media Player事件而不使用额外的脚本标签
- 我可以从Windows脚本语言(如JScript)写入Windows事件日志吗?