### Bat2Com Success Secret Technique Tutorial
First, off-topic remarks, those who don't like it or have different views, please excuse:
1. It's about DOS, so CMD can be ignored.
2. Found a tall building about BAT encryption on the CN-DOS forum, climbed from floor 1 to floor 350 in one go, tested it, and the result was: extremely disappointed. These so-called encryptions can be said to be self-deceiving. The simplest cracking method is to first compress with RAR, then view with RAR, and the encryption is clear at a glance. So I advise everyone, don't waste time and energy on BAT encryption anymore.
3. If you must encrypt BAT, only bat2com. Some people said that the success rate of bat2com converting BAT to COM or EXE is very low. It's indeed like that. I tried several times before, and there were few successes. Then why am I still talking about this?
Wait a minute, I can responsibly tell you that bat2com is really good and practical.
Back to the main topic
### 1. Analysis of Reasons for Unsuccessful Conversion
1. Undoubtedly, bat2com is not omnipotent, has certain limitations, and has a few BUGs. This is one of the reasons for unsuccessful conversion.
2. You may not be very familiar with the processing specifications of bat2com, or your BAT program is not written according to the specifications of bat2com, or it exceeds the processing capacity range of bat2com. This is the most main reason for unsuccessful conversion.
The reason why bat2com is not successful is the same as the reason why most CMDs don't run successfully under DOS. As long as you write CMD according to the DOS specifications, then CMD can run successfully under DOS. Nonsense:))
The key question: Is it waiting for the author of bat2com to modify and upgrade his program to adapt to your BAT, or modifying your BAT to make your BAT adapt to the requirements of bat2com. Success or failure, this is a question.
### 2. Conversion Specifications of bat2com (Taking the bat2com V1.5 in my hand as an example)
bat2com handles it according to the specifications of BAT and has good support for BAT:
1. Directly support DOS internal commands, external commands, and can take parameters.
2. Directly support IF, goto commands, and support the labels of GOTO.
3. Ignore REM comment lines.
4. The for command is unique and is executed directly in BAT mode.
5. Only one command is executed in each line, and each command must be completed in one line, that is, | and > commands are basically not supported.
Items 1-4 are consistent with the general BAT requirements. Only item 5 is a major difference from the conventional BAT!!
### 3. Basic Requirements, First Note Two Points:
1. The goto labels (: start) cannot be repeated, which is stricter than the requirements of BAT.
2. Ensure that your BAT can be correctly executed in DOS in BAT mode. This is the prerequisite condition. Don't think this is nonsense.
### 4. Interpreting the Important Differences Between bat2com and BAT
(1) The most main one: Only one command is executed in each line, and each command must be completed in one line, that is, | and > commands are basically not supported 1. Only one command can be executed in each line, that is, "|" (pipe) is not allowed.
2. Except for echo or dir, no other cases are allowed to have redirection commands (>,>>).
For example: type a.txt | find "abc" --> Illegal (cannot have |)
Another example: find "abc' a.txt >b.txt ---> Illegal (cannot have >)
Another example: External command dspt.exe 0 /l >d.txt ---> Illegal (cannot have >)
Another example: for %%i in (%a%) do echo %%i >>c.txt -> Illegal (cannot have >, >>)
Another example: if %a%==1 if %b%==2 set c=3 --> Illegal (cannot execute continuously)
I bet that the reason why the success rate of BAT2com is low is that most BATs are because of this one item!
If there are no similar texts in your BAT, I believe that your bat2com has been 90% successful.
How about it, a little bit clear? Don't worry, it's not over yet.
(2) The call command will not return parameters
For example:
set a=123
call b.bat ------> The command in b.bat is: set a=abc
echo %a%
For the BAT mode, after executing the above command, the result of echo is: abc
This is the most commonly used BAT command call, that is, BAT transmits variables.
However, for bat2com, the result of its execution is: 123 ------》 Correct, still 123!
Really correct. This is not a Bug of Bat2com, nor a Bug of BAT. This is the standard execution method of COM, EXE.
In fact, this should be easy to understand. This is the same as an EXE program cannot directly pass parameters to another EXE program.
For example, if your BAT uses wbat.com, and there is a w.bat in it, if after bat2com, the parameters passed by w.bat will be invalid.
If you know what global variables and local variables are, then you should understand it at once. If you still don't understand, you can read relevant books. You can also do the following test:
Execute the following commands, and you will understand:
set a=123
echo %a% -------> The result is: 123, correct
command /k
set a=abc
echo %a% -------> Display: abc, also correct
exit
echo %a% -------》 What is the result, is it 123 or abc? Do it yourself.
It is the simple display of global variables and local variables. Of course, if your BAT does not have the call command at all, then you will not care.
(3) A very small number of third-party software, after bat2com, run abnormally. No one is perfect, don't be too demanding. Determine after testing. If it really doesn't work, then Call.
### 5. bat2com has two serious BUGs, which must be avoided:
1. Variable names. For example, if there is in BAT:
set a=1
set ab=2
set abc=3
These three commands are executed correctly in BAT, but in BAT2com, they will be considered the same, and an error will occur. This is a BUG. Just avoid it: that is, the variable names should not be completely coincident.
2. echo set a=c:>a.txt
echo dir %%a%%>>a.txt
These two commands are executed correctly in BAT, but in bat2com, there will be several spaces after "c:" and %a%,
set a=c: becomes set a=c: , an error will occur. This is also a BUG. Ordinary text output is okay. If necessary, also avoid it.
### 6. Recommended Solutions
If you re-modify your BAT program according to the above requirements, the success of bat2com is just around the corner!
1. Call the subroutine BAT through call to execute | or > commands.
You will definitely say that my program must have such as: type a.txt | find "abc" or dspt.exe 0 /l >d.txt or echo set a=c:>a.txt
It's very simple! Treat it as a subroutine BAT and call it through call. Remember, the subroutine should not be bat2com again!
2. The parameters of the subroutine cannot be passed to bat2com through the set command. It can be passed through the file method, such as
echo %your parameter% >a.txt
Then read the content of a.txt as a parameter in the main program. This is also the standard way to pass parameters between EXE files.
7. Vigorously Recommended: strings.com
There are many downloads and introductions of trings.com on the forum. Please search by yourself.
I just want to say that strings is the best partner of DOS-BAT. With strings, almost any operation that BAT wants to complete can be done. If there is no strings, I definitely would not write this article.
For example, echo echo 123>b.txt >a.bat, or echo type a.txt | find "abc" >a.bat
It is very difficult to make the above be successfully executed in BAT to get the correct a.bat (it can be done through prompt variation, but it is more complicated). It is absolutely impossible in bat2com. However, strings can easily do it!
The write command of strings can perfectly replace echo, and for symbols like >| that echo does not recognize, it is very well solved. For example:
strings write a.bat,strings vhao=char 62 --》 set vhao=>
strings write a.bat, echo 123%%vhao%%b.txt --》 echo echo 123>b.txt >a.bat
Among them, Vhao is >, which can be arbitrarily defined as |, etc. Run a.bat to get b.txt.
Handling the parameters returned by call, variable operations, analysis and processing, etc., strings can easily do it.
strings has many functions, so I recommend it.
### 8. Supplementary:
1. It is recommended to carry out bat2com in the DOS environment.
2. Before any bat2com, it must be ensured that the BAT file can run correctly.
3. The COM file must not be larger than 64KB!
4. After bat2com can be executed correctly, then execute com2exe to convert the file to EXE.
### 9. Postscript:
In order to ensure data security, I have been looking for a method of BAT encryption or 2com. As mentioned above, after several disappointments, I later wanted to make a for DOS program by myself. But I haven't played C++ for nearly 10 years. It's headache. Later, I found the original program of bat2com. After taking a close look, it was just what I wanted. I gradually understood the reasons for the previous unsuccessful conversion. After several tests, I finally succeeded in bat2com.
If the author of bat2com can see this article, it is best to correct the BUGs and upgrade bat2com, or wait until I have time one day, take up C++ again, and help him improve it.
Sincerely thank the author of bat2com (cannot be sure if it is Dong Zhanshan), the author of strings, the Chinese translation of strings (insert of cn-dos), and the enthusiastic DOS experts of the China DOS Union!
Well, this is the experience I got after several tests. There are inevitable mistakes and omissions. Welcome to supplement, improve and correct.
Welcome to communicate, Ge Li QQ107660899 2008.12.02
The attachment is: bat2com\com2exe\stringsSample Text
[ Last edited by goli2008 on 2008-12-2 at 11:10 ]
First, off-topic remarks, those who don't like it or have different views, please excuse:
1. It's about DOS, so CMD can be ignored.
2. Found a tall building about BAT encryption on the CN-DOS forum, climbed from floor 1 to floor 350 in one go, tested it, and the result was: extremely disappointed. These so-called encryptions can be said to be self-deceiving. The simplest cracking method is to first compress with RAR, then view with RAR, and the encryption is clear at a glance. So I advise everyone, don't waste time and energy on BAT encryption anymore.
3. If you must encrypt BAT, only bat2com. Some people said that the success rate of bat2com converting BAT to COM or EXE is very low. It's indeed like that. I tried several times before, and there were few successes. Then why am I still talking about this?
Wait a minute, I can responsibly tell you that bat2com is really good and practical.
Back to the main topic
### 1. Analysis of Reasons for Unsuccessful Conversion
1. Undoubtedly, bat2com is not omnipotent, has certain limitations, and has a few BUGs. This is one of the reasons for unsuccessful conversion.
2. You may not be very familiar with the processing specifications of bat2com, or your BAT program is not written according to the specifications of bat2com, or it exceeds the processing capacity range of bat2com. This is the most main reason for unsuccessful conversion.
The reason why bat2com is not successful is the same as the reason why most CMDs don't run successfully under DOS. As long as you write CMD according to the DOS specifications, then CMD can run successfully under DOS. Nonsense:))
The key question: Is it waiting for the author of bat2com to modify and upgrade his program to adapt to your BAT, or modifying your BAT to make your BAT adapt to the requirements of bat2com. Success or failure, this is a question.
### 2. Conversion Specifications of bat2com (Taking the bat2com V1.5 in my hand as an example)
bat2com handles it according to the specifications of BAT and has good support for BAT:
1. Directly support DOS internal commands, external commands, and can take parameters.
2. Directly support IF, goto commands, and support the labels of GOTO.
3. Ignore REM comment lines.
4. The for command is unique and is executed directly in BAT mode.
5. Only one command is executed in each line, and each command must be completed in one line, that is, | and > commands are basically not supported.
Items 1-4 are consistent with the general BAT requirements. Only item 5 is a major difference from the conventional BAT!!
### 3. Basic Requirements, First Note Two Points:
1. The goto labels (: start) cannot be repeated, which is stricter than the requirements of BAT.
2. Ensure that your BAT can be correctly executed in DOS in BAT mode. This is the prerequisite condition. Don't think this is nonsense.
### 4. Interpreting the Important Differences Between bat2com and BAT
(1) The most main one: Only one command is executed in each line, and each command must be completed in one line, that is, | and > commands are basically not supported 1. Only one command can be executed in each line, that is, "|" (pipe) is not allowed.
2. Except for echo or dir, no other cases are allowed to have redirection commands (>,>>).
For example: type a.txt | find "abc" --> Illegal (cannot have |)
Another example: find "abc' a.txt >b.txt ---> Illegal (cannot have >)
Another example: External command dspt.exe 0 /l >d.txt ---> Illegal (cannot have >)
Another example: for %%i in (%a%) do echo %%i >>c.txt -> Illegal (cannot have >, >>)
Another example: if %a%==1 if %b%==2 set c=3 --> Illegal (cannot execute continuously)
I bet that the reason why the success rate of BAT2com is low is that most BATs are because of this one item!
If there are no similar texts in your BAT, I believe that your bat2com has been 90% successful.
How about it, a little bit clear? Don't worry, it's not over yet.
(2) The call command will not return parameters
For example:
set a=123
call b.bat ------> The command in b.bat is: set a=abc
echo %a%
For the BAT mode, after executing the above command, the result of echo is: abc
This is the most commonly used BAT command call, that is, BAT transmits variables.
However, for bat2com, the result of its execution is: 123 ------》 Correct, still 123!
Really correct. This is not a Bug of Bat2com, nor a Bug of BAT. This is the standard execution method of COM, EXE.
In fact, this should be easy to understand. This is the same as an EXE program cannot directly pass parameters to another EXE program.
For example, if your BAT uses wbat.com, and there is a w.bat in it, if after bat2com, the parameters passed by w.bat will be invalid.
If you know what global variables and local variables are, then you should understand it at once. If you still don't understand, you can read relevant books. You can also do the following test:
Execute the following commands, and you will understand:
set a=123
echo %a% -------> The result is: 123, correct
command /k
set a=abc
echo %a% -------> Display: abc, also correct
exit
echo %a% -------》 What is the result, is it 123 or abc? Do it yourself.
It is the simple display of global variables and local variables. Of course, if your BAT does not have the call command at all, then you will not care.
(3) A very small number of third-party software, after bat2com, run abnormally. No one is perfect, don't be too demanding. Determine after testing. If it really doesn't work, then Call.
### 5. bat2com has two serious BUGs, which must be avoided:
1. Variable names. For example, if there is in BAT:
set a=1
set ab=2
set abc=3
These three commands are executed correctly in BAT, but in BAT2com, they will be considered the same, and an error will occur. This is a BUG. Just avoid it: that is, the variable names should not be completely coincident.
2. echo set a=c:>a.txt
echo dir %%a%%>>a.txt
These two commands are executed correctly in BAT, but in bat2com, there will be several spaces after "c:" and %a%,
set a=c: becomes set a=c: , an error will occur. This is also a BUG. Ordinary text output is okay. If necessary, also avoid it.
### 6. Recommended Solutions
If you re-modify your BAT program according to the above requirements, the success of bat2com is just around the corner!
1. Call the subroutine BAT through call to execute | or > commands.
You will definitely say that my program must have such as: type a.txt | find "abc" or dspt.exe 0 /l >d.txt or echo set a=c:>a.txt
It's very simple! Treat it as a subroutine BAT and call it through call. Remember, the subroutine should not be bat2com again!
2. The parameters of the subroutine cannot be passed to bat2com through the set command. It can be passed through the file method, such as
echo %your parameter% >a.txt
Then read the content of a.txt as a parameter in the main program. This is also the standard way to pass parameters between EXE files.
7. Vigorously Recommended: strings.com
There are many downloads and introductions of trings.com on the forum. Please search by yourself.
I just want to say that strings is the best partner of DOS-BAT. With strings, almost any operation that BAT wants to complete can be done. If there is no strings, I definitely would not write this article.
For example, echo echo 123>b.txt >a.bat, or echo type a.txt | find "abc" >a.bat
It is very difficult to make the above be successfully executed in BAT to get the correct a.bat (it can be done through prompt variation, but it is more complicated). It is absolutely impossible in bat2com. However, strings can easily do it!
The write command of strings can perfectly replace echo, and for symbols like >| that echo does not recognize, it is very well solved. For example:
strings write a.bat,strings vhao=char 62 --》 set vhao=>
strings write a.bat, echo 123%%vhao%%b.txt --》 echo echo 123>b.txt >a.bat
Among them, Vhao is >, which can be arbitrarily defined as |, etc. Run a.bat to get b.txt.
Handling the parameters returned by call, variable operations, analysis and processing, etc., strings can easily do it.
strings has many functions, so I recommend it.
### 8. Supplementary:
1. It is recommended to carry out bat2com in the DOS environment.
2. Before any bat2com, it must be ensured that the BAT file can run correctly.
3. The COM file must not be larger than 64KB!
4. After bat2com can be executed correctly, then execute com2exe to convert the file to EXE.
### 9. Postscript:
In order to ensure data security, I have been looking for a method of BAT encryption or 2com. As mentioned above, after several disappointments, I later wanted to make a for DOS program by myself. But I haven't played C++ for nearly 10 years. It's headache. Later, I found the original program of bat2com. After taking a close look, it was just what I wanted. I gradually understood the reasons for the previous unsuccessful conversion. After several tests, I finally succeeded in bat2com.
If the author of bat2com can see this article, it is best to correct the BUGs and upgrade bat2com, or wait until I have time one day, take up C++ again, and help him improve it.
Sincerely thank the author of bat2com (cannot be sure if it is Dong Zhanshan), the author of strings, the Chinese translation of strings (insert of cn-dos), and the enthusiastic DOS experts of the China DOS Union!
Well, this is the experience I got after several tests. There are inevitable mistakes and omissions. Welcome to supplement, improve and correct.
Welcome to communicate, Ge Li QQ107660899 2008.12.02
The attachment is: bat2com\com2exe\stringsSample Text
[ Last edited by goli2008 on 2008-12-2 at 11:10 ]
Recent Ratings for This Post
( 6 in total)
Click for details
Attachments

