包装一个可执行文件以诊断它的调用 [英] Wrap an executable to diagnose it's invocations

查看:38
本文介绍了包装一个可执行文件以诊断它的调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Windows 可执行文件 (whoami),它经常崩溃.它从另一个进程调用以获取有关当前用户和域的详细信息.我想知道失败时传递了哪些参数.

I have a Windows executable (whoami) which is crashing every so often. It's called from another process to get details about the current user and domain. I'd like to know what parameters are passed when it fails.

有没有人知道一种适当的方法来包装进程并将其命令行参数写入日志,同时仍然调用进程?

Does anyone know of an appropriate way to wrap the process and write it's command line arguments to log while still calling the process?

说命令是这样使用的:'whoami.exe/all'

Say the command is used like this: 'whoami.exe /all'

我想要一个脚本而不是 whoami.exe(具有相同的文件名),它将将此调用写入日志,然后将调用传递给实际进程.

I'd like a script to exist instead of the whoami.exe (with the same filename) which will write this invocation to log and then pass on the call to the actual process.

推荐答案

来自批处理文件:

echo Parameters: %* >> logfile.txt
whoami.exe %*

需要注意的是,如果参数包含空格(并且您将 in 转义为),您可能会遇到问题,因为命令行解析器基本上对它们进行了转义,并且在传递给另一个之前应该重新转义它们可执行.

With the caveat that you can have problems if the parameters contain spaces (and you passed the in escaping with "), because the command-line parser basically de-escapes them and they should be re-escaped before passed to an other executable.

这篇关于包装一个可执行文件以诊断它的调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆