计算批处理脚本的执行次数

发布于 2024-10-18 12:12:12 字数 226 浏览 4 评论 0原文

这是我的问题,我有一个无法修改的批处理脚本(我们称之为 foo),我想计算该脚本每天执行的次数 - 以跟踪该数据。

最好,我想将带有日期和退出代码的执行次数写入某种日志文件。

所以我的问题是这是否可能,在这种情况下如何?创建一个批处理脚本/在后台运行的东西并将 foo 的每次执行写入日志。

(我知道如果我可以修改 foo 这会很容易,但我不能。而且,一切都在 WinXP 机器上运行。)

This is my problem, I've got a batch-script that I can't modify (lets call it foo) and I would like to count how many times/day this script is executed - to keep track of that data.

Preferably, I would like to write the number of executions with date and exit-code to some kind of log file.

So my question is if this is possible and in that case - how? To create a batch-script/something that works in the background and writes every execution of foo to a log.

(I know this would be easy if I could modify foo but I can't. Also, everything is running on WinXP machines.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

℡Ms空城旧梦 2024-10-25 12:12:12

您可以编写一个包装器脚本来执行日志记录并调用现有脚本。然后使用包装器代替原始脚本

You could write a wrapper script that does the logging and calls the existing script. Then use the wrapper in place of the original script

就此别过 2024-10-25 12:12:12

考虑编写一个询问任务管理器的程序。

请参阅 http://www.netomatix.com/ProcDiagnostics.aspx

例如,您可以编写一个在计时器上运行的简单控制台应用程序;每 5 秒它会检查您的 foo 应用程序进程是否存在。如果发现存在,则假定 find 作为应用程序的启动时间;如果没有找到,它会假设应用程序现已关闭并记录该信息。无论如何,它都不会精确到秒,但会给你一个粗略的近似值,告诉你事物何时运行和关闭。

Consider writing a program that interrogates the Task Manager.

See http://www.netomatix.com/ProcDiagnostics.aspx

You could, for example, write a simple Console app which runs on a timer; every 5 seconds it checks that your foo application process exists. If it finds that it does, it assumes that find as the start time of the application; if it doesn't find it, it assumes the application has now closed and logs that information. It wouldn't be accurate to the second by any means, but would give you a rough approximation of when the thing is running and closing.

浊酒尽余欢 2024-10-25 12:12:12

您也许可以配置进程监视器
http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx 捕获您需要的信息

You might be able to configure Process Monitor
http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx to capture the information you require

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文