China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-28 01:43
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Convert batch files into executable files View 2,576 Replies 5
Original Poster Posted 2002-12-03 00:00 ·  中国 湖北 黄石 联通
初级用户
Credits 167
Posts 23
Joined 2002-10-18 00:00
23-year member
UID 22
Gender Male
Status Offline
TC2.0 provides a system() function. This function can execute
commands in DOS and COMMAND.COM from within a running C program. By using this function, we can very conveniently convert batch files
into executable files. The method is as follows:
For example, the batch file Sample.bat
c:
cd c:\dos
dir/p
The corresponding C program is as follows:
Sample.c
#include //the system() function is included in this library
main()
{
system("c:");
system("cd c:\dos");
system("dir/p");
}
Compile Sample.c into an executable file, and running this file will achieve the function of Sample.bat.
Floor 2 Posted 2002-12-03 00:00 ·  中国 广东 佛山 三水区 电信
元老会员
★★★★
Credits 5,170
Posts 1,637
Joined 2002-10-16 00:00
23-year member
UID 8
Gender Male
From 广东佛山
Status Offline
It works, but doing it this way means every time you call a command you have to load a copy of command.com.
In actual use it probably isn't as good as tools like BAT2EXE.
我的网志
http://hzmys.blog.163.com/
我的网盘
firststep.qjwm.com
fsmys.ys168.com
ssmys.ys168.com
www.brsbox.com/fsmys
www.brsbox.com/ssmys
www.brsbox.com/ccdos
Floor 3 Posted 2002-12-04 00:00 ·  中国 湖北 黄石 联通
初级用户
Credits 167
Posts 23
Joined 2002-10-18 00:00
23-year member
UID 22
Gender Male
Status Offline
BAT2EXE is probably also written in C, right? I don't know, but in a few months I will know

Because I once saw a section of C code called typeWps that could directly display WPS document files,
I think this and BAT2EXE may be somewhat similar in concept.


Work hard.....work even harder, I also want to emulate a BAT2EXE

Thank you.
Floor 4 Posted 2002-12-04 00:00 ·  中国 湖北 宜昌 联通
初级用户
Credits 167
Posts 23
Joined 2002-10-18 00:00
23-year member
UID 22
Gender Male
Status Offline
COMMAND.COM is the command interpreter. Doesn't BAT2EXE also need a command interpreter?

If that's really the case, then I'll have to study compiler theory. A few months may not be enough, maybe a year .


If I've written anything wrong, please point it out to me.

Thanks, everyone.
Floor 5 Posted 2009-05-29 02:26 ·  中国 贵州 遵义 电信
初级用户
Credits 20
Posts 20
Joined 2009-04-10 03:30
17-year member
UID 142557
Gender Male
Status Offline
Give this a try. If it can be made resistant to cracking, it should turn out quite well.
Floor 6 Posted 2009-05-29 11:54 ·  中国 广东 广州 番禺区 电信
初级用户
★★
Credits 111
Posts 62
Joined 2007-12-31 20:10
18-year member
UID 107336
Gender Male
Status Offline
The system approach is pure wishful thinking

Labels won't work, variables won't work, and there are a whole bunch of other problems

Every time the system function is executed, it creates a command process to run it, and destroys it as soon as it finishes, leaving nothing behind

This approach doesn't have much value anymore...
Forum Jump: