开发者

How to create a batch file from .exe file?

I want to know simply how to create a batch f开发者_Go百科ile from .exe file?


If you mean you want to create a new batch file from an unrelated existing executable file (in other words, the batch file does something different), you do it the way you create any file. In C, you'd use fopen, fwrite and fclose to create your new file and write whatever batch file commands you want to it.

If you mean you want to create a batch file that "intercepts" your exe file, you can do that too. If your executable file is pax.exe, you can simply rename it to pax2.exe and create a batch file called pax.cmd thus:

@echo off
pax2.exe

This will allow you to do arbitrary actions before and after your executable runs but there are things to watch out for such as executables that return control before they're actually finsihed.

If, however, you're talking about converting an arbitrary executable into a batch file that performs the same task, that's much more difficult. Unless you have the source code or a very good specification on how the executable works, you're going to have a lot of trouble.

Automating the conversion for anything but the simplest executable will be insanely difficult.


And, if you want a link to a batch file that runs your executable, just create the batch file (say in c:\bin\pax.cmd) containing:

@echo off
c:\bin\pax.exe

and then create a shortcut to it from wherever you want (such as the desktop). You could even put the batch file itself in your desktop directory but I'm not a big fan of that. However, to each their own.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜