Computer Hope
Microsoft => Microsoft DOS => Topic started by: banjo67xxx on November 28, 2009, 01:02:43 PM
-
Hi,
I'm trying to intercept calls to a .exe to trace them (legit as my company wrote the .exe) as part of debugging, and I've suceeded in writing a short .bat file which does what I want after renaming the original command with -ORIG.
the-command.bat
@echo off
echo .|time >> logfile.txt
echo %0 %* >> logfile.txt
the-command-ORIG.exe %*
The problem is that the customer's program is expecting to call the-command.exe not the-command.bat.
I tried renaming the .bat file, but then it won't execute.
I tried creating a shortcut with .exe extension to the .bat but that didn't work either.
Is there a compiler I could use to convert it from .bat to .exe?
or do I need to write a one-line program to call the .bat and compile it?
or would it be a whole lot easier to write a C program to do the tracing instead?
-
I've nearly solved it with MinGW and the following code
#include <unistd.h>
#include <stdio.h>
main(int argc, char *argv[])
{
argv[0] = "C:\\path\\etc\\the-command.bat";
execv("C:\\path\\etc\\the-command.bat", argv);
return 0;
}
I'll follow up on the final problems in the programming forum.