小编and*_*dyb的帖子

Get-EventLog - 某些事件日志源缺少有效消息

我正在使用get-eventlog来提取和过滤系统事件日志数据.我发现,get-event日志无法正确返回与某些条目相关的消息.这些条目通常出现在事件日志查看器中.例如

get-eventlog -logname system | ? { $_.source -eq "Microsoft-Windows-Kernel-General" }
Run Code Online (Sandbox Code Playgroud)

返回8个条目,所有条目都有以下格式的消息:

The description for Event ID '12' in Source 'Microsoft-Windows-Kernel-General' cannot be found.  
The local computer may not have the necessary registry information or message DLL files to display the message, or you may not have permission to access them.  
The following information is part of the event:'6', '1', '7601', '18798', '1', '0', '2015-06-13T08:33:32.359599800Z'
Run Code Online (Sandbox Code Playgroud)

如果我过滤同一来源的系统事件日志,我可以清楚地看到完整形成的消息.例如

The operating system started at system time ?2015?-?06?-?13T08:33:32.359599800Z.
Run Code Online (Sandbox Code Playgroud)

我运行以下命令以查看是否有任何其他提供程序无法返回有效的事件消息:

get-eventlog -LogName system | ? …
Run Code Online (Sandbox Code Playgroud)

powershell event-log get-eventlog

5
推荐指数
1
解决办法
1878
查看次数

如何使用批处理文件获取文件的独占锁定?

我有一个项目,我需要监视批处理文件,该文件不断运行以查看它是否仍然有效.我有一台远程机器需要监视在另一台服务器上运行的批处理文件.

我需要做的是让批处理文件创建并独占锁定一个文本文件(可以是空的,可以是满的并不重要).这是我可以从我的远程机器(使用由c#创建的exe)轮询它以查看文件是否有独占锁 - 如果是,则不执行任何操作.如果可以获得锁定,则发出警报(因为批处理失败).

理解这可能不是最好的方法,但不幸的是它是我必须要做的.那么,有没有办法使用批处理文件独占锁定文件?

windows cmd locking batch-file

4
推荐指数
1
解决办法
5354
查看次数