Re tuliplanet:
很有趣的一个题目,根据你的要求我写了下面这段 BatDump 代码,它只能 Dump 一些简单的批处理,遇到某些复杂的批处理时,会有许多意想不到的问题,毕竟它不是程序的正常执行流程。另外,如果待 Dump 的批处理中含有 pause 等需要接受键盘输入的语句,Dump 过程中需要“摸黑”进行选择确定(CMD中的情况比较特殊)。
:: BatDump.bat - V2 - Dump process of batch program
:: Will Sort - 2005-12-06 - CMD@WinXP/MSDOS7.10/MSDOS6.22
@echo off
if not "%1"=="" if exist %1.bat goto Dump
:Usage
echo.
echo BatDump - Dump process of batch program
echo Usage: %0 batname(without extname)
echo Sample: %0 test
echo.
goto end
<img src="images/smilies/face-smile-big.png" align="absmiddle" border="0">ump
ren %1.bat %1.bak
echo @echo off>%1.bat
echo set prompt=# >>%1.bat
echo echo on>> %1.bat
find /v "echo off" < %1.bak >> %1.bat
shift
%comspec% /c %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 | find "#"
if exist %0.bat del %0.bat
ren %0.bak %0.bat
:end
Re tuliplanet:
A very interesting topic. According to your requirements, I wrote the following BatDump code. It can only dump some simple batch scripts. When encountering some complex batch scripts, there will be many unexpected problems, after all, it is not the normal execution process of a program. In addition, if the batch script to be dumped contains statements like pause that need to accept keyboard input, the selection confirmation needs to be done "in the dark" during the dumping process (the situation in CMD is relatively special).
:: BatDump.bat - V2 - Dump process of batch program
:: Will Sort - 2005-12-06 - CMD@WinXP/MSDOS7.10/MSDOS6.22
@echo off
if not "%1"=="" if exist %1.bat goto Dump
:Usage
echo.
echo BatDump - Dump process of batch program
echo Usage: %0 batname(without extname)
echo Sample: %0 test
echo.
goto end
:Dump
ren %1.bat %1.bak
echo @echo off>%1.bat
echo set prompt=# >>%1.bat
echo echo on>> %1.bat
find /v "echo off" < %1.bak >> %1.bat
shift
%comspec% /c %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 | find "#"
if exist %0.bat del %0.bat
ren %0.bak %0.bat
:end